3

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:

harbir:x:1000:100:harbir:/home/harbir:/bin/bash
kdm:x:489:487:KDM Display Manager daemon:/var/lib/kdm:/bin/false
harbir-PC:x:1001:100::/home/harbir-PC:/bin/bash

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.

2
  • 5
    Have you checked the documentation of useradd? It says -p The encrypted password, as returned by crypt(3).
    – choroba
    Jul 1, 2014 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, 2014 at 21:32

1 Answer 1

5

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.

2
  • 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, 2014 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)". Jul 2, 2014 at 12:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .