I am running ubuntu 14.04 LTS. I ran the following command to create a user
$sudo useradd -m -p password1 guest_user
and then tried to switch to the user with
$su guest_user
But i could not login with password1
Am i missing something? Am i suppose to login with password1 or something else as -p option says in the man page for useradd
-p, --password PASSWORD
The encrypted password, as returned by crypt(3). The default is to disable the password.
Note: This option is not recommended because the password (or encrypted password) will be
visible by users listing the processes.
You should make sure the password respects the system's password policy.
The above confuses me because when i type the command
useradd -m -p password1
the password password1 is visible on the command line. How to make it invisible in the above command?
Best Answer
From
man useradd
:As you can see the
PASSWORD
with-p
option is the encrypted password returned by thecrypt(3)
library function.If you use
-p password1
, the system will consider this plain textpassword1
as the encrypted shadow password entry in/etc/shadow
.The solution is to use the encrypted password here with
-p
which is unsafe, you should set the password interactively.For example create the suer first :
Now set the password :
Or better use
adduser
instead :