Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

migrated from stackoverflow.com Mar 30 '10 at 4:22

This question came from our site for professional and enthusiast programmers.

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer
    
You might also want to use the "-v" flag with ssh, to see more verbose output, e.g. "ssh -vv marco@<host>". –  wolfgangsz Mar 30 '10 at 9:24

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.