I am using openSuse 12.3.

I have created a new user using:

linux-amvn:~ # useradd -m -G users,dev -s /bin/bash -p pass123 harbir-PC

The user harbir-PC is not able to login, when I try to log using ssh. I went ahead and looked into the /etc/passwd file and I see the following:

kdm:x:489:487:KDM Display Manager daemon:/var/lib/kdm:/bin/false

There is a difference between the user harbir and harbir-PC.

I have no problem with the user harbir (who I have created during installation), but I need to login using the user harbir-PC.

I also checked the /etc/shadow, and passwords are encrypted.

  • 5
    Have you checked the documentation of useradd? It says -p The encrypted password, as returned by crypt(3). – choroba Jul 1 '14 at 20:46
  • From man page of useradd if you look for option p, it has the information as specified above and it has this information as well. The default is to disable the account. – Ramesh Jul 1 '14 at 21:32

I usually run passwd after useradd to set the password as I want it. But if you are provisioning and doing this from a script you may need to use crypt and provide the encrypted password on the command line.

  • yea, I ran passwd separately after creating the user, and now the user is being able to log in, just wondering why wouldn't it work earlier. – Harbir Jul 2 '14 at 10:08
  • As mentioned, the argument to useradd's -p option needs to be an encrypted password, not a clear-text password. So you need to use crypt first to get the encrypted form of the clear-text password, and then use that. This is described on the useradd man page: "The encrypted password, as returned by crypt(3)". – BobDoolittle Jul 2 '14 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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