Added a new user on Ubuntu, set password not working

groupusers

I created a new user:

$ sudo useradd -m Ari -p pass123

But when I went to login it said the password was incorrect, I know it's correct because I saved the command line log as a text file.

Other than that, at the same time I also created a group:

$ sudo groupadd testgroup1

and added the new account to it:

$ sudo usermod -a -G testgroup1 Ari

Why can't a log in?

Best Answer

The -p option is looking for an encrypted password:

-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.

You should use the following to change the password:

sudo passwd Ari

In order to use the -p option you must first encrypt the password. You can use some of the methods mentioned here such as:

$ mkpasswd
Password:
1puqSPGTnyi5o
$ sudo useradd -m Ari -p 1puqSPGTnyi5o

Note the mkpasswd utility is included in the whois package which can be obtained through apt

Related Question