3

How can I create a new user then SSH into the box under that user?

I ran:

useradd marco -d /home/marco -p WuUfhRdt4B

Then I added to /etc/ssh/sshd_config:

AllowUsers root marco

Then restarted ssh:

/etc/init.d/ssh restart

I can't login. What did I miss?

** Running Debian.

Miko
  • 1,759
  • 4
  • 22
  • 28

2 Answers2

5

The first thing I see is that you didn't specifically add a shell, you can ensure that the users shell is correct by running as root:

chsh -s `which bash` marco

The other thing to ensure is that the home directory was created by the useradd script.

ls -al /home/marco/

If it was not created you'll need to create it and change the ownership to the correct user:

mkdir /home/marco
cp -a /etc/skel/.[a-z]* /home/marco
chown -R marco.marco /home/marco

I would also make sure that your password was correctly placed in /etc/shadow as I never trust it from the command line:

passwd marco

And enter the password for marco (BTW, it's a really really bad idea to put a password anywhere but in a password field that is not shown. History files are extremely easy to read, as is serverfault :) Make sure you change marcos password is all I'm saying)

If you still can't login check /var/log/auth, /var/log/messages, /var/log/secure etc for sshd entries, it should give you a pretty good idea as to what is failing.

d34dh0r53
  • 1,781
  • 11
  • 11
3

In your example, is WuUfhRdt4B meant to be the user's password? That won't work because the argument to useradd -p is (according to the man page) "the encrypted password, as returned by crypt(3)." You probably want to use adduser anyway, since it's a lot more intuitive than useradd. Try this:

adduser marco

ʇsәɹoɈ
  • 241
  • 2
  • 4