I have created user using below command

useradd myuser

Then, I tried to do change password with following command

usermod --password mypwd myuser

(I know plain password is not a good way, but for time being I am doing this)

I have tried to login myuser with mypwd. But, it's not allowing to login (incorrect password).

I could use passwd myuser (working fine). There are some constraints, so I am doing with usermod.

Is anything I am missing in usermod ? or Is there any alternatives to do change password other than passwd username?


The parameter given to usermod --password is expected to be the encrypted password, as returned by the crypt() function. If you look in /etc/shadow (assuming you're using local password storage) you'll see the string you specified stored as-is in myuser's entry...

If you really want to use usermod for this, you can generate the appropriate value using openssl passwd:

usermod --password $(openssl passwd mypwd) myuser

or better still

usermod --password $(openssl passwd -1 mypwd) myuser
| improve this answer | |

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.