Ubuntu – How to login with new user and fix error : “: No such file or directory”

rootsshsuuseradd

I created a user with root access

useradd -ou 0 -g 0 myuser -p [12345]

when I try to su to the new user, I get:

: No such file or directory

when I want to connect as that user via ssh, I get:

Permission denied, please try again.

So, I checked /etc/passwd:

myuser:x:0:0::/home/myuser:/bin/bash

To test it, I created another user without root access and it worked very well.

I also added this line to /etc/sudoers but it still doesn't work:

root ALL=(ALL) ALL
myuser ALL=(ALL) ALL

I then changed PermitRootLogin in sshd_config but still no luck 🙁

How can I create a user with root access and ssh into my machine as that user?

Best Answer

Usually on Linux there is only one user root, and on Ubuntu it is deactivated. Instead it is a better idea to add all users that should have administrative privilieges to the group sudo by executing

adduser username sudo

as root. That allows them to execute commands as root by typing

sudo command

and get a root shell by

sudo -i

On top op that, you don't have to enable root login for ssh that way.

The home directory probably wasn't created because you added a user with an id (0) that already existed. Avoid setting the userid and groupid manually.


Step-by-Step how-to create an admin user:

  1. sudo adduser username
  2. sudo adduser username sudo