How to change password using usermod?
The usermod -p
flag is expecting the data to be the password already in an encrypted format.
Use openssl passwd
to generate the encrypted data, or do it like this:
usermod -p `openssl passwd` (USERNAME)
The reason it didn't work is because usermod
's -p option expects the password to be encrypted already.
From usermod
's man page:
-p, --password PASSWORD
The encrypted password, as returned by crypt(3).
To set a password in this way is not recommended.
Instead You should use passwd <username>
. This should (as usermod
) be done as root (if you're not changing the currently logged in users password).
To change the password for user foo.
sudo passwd foo
This will prompt for a new password.
Have a look at the man-page for passwd
for more info on setting for example expire time.
Good Luck!
You may use passwd
:
sudo passwd USERNAME
You need not sudo
if you're superuser yourself