2

After trying to change my password with usermod -p <new password> <username> ( which seemed to work but didn't give any messages ) I found I could not log in using either my old or new password. From what I've read it looks like maybe this is due to usermod expecting the password given to be encrypted?

How can I get back in?

3 Answers 3

3

Yes, this problem happened because usermod -p expected the password hash (i.e., the encrypted password), not the cleartext password.

From man 8 usermod:

-p, --password PASSWORD

The encrypted password, as returned by crypt.

Note: This option is not recommended because the password (or encrypted password) will be visible by users listing the processes.

The password will be written in the local /etc/passwd or /etc/shadow file. This might differ from the password database configured in your PAM configuration.

You should make sure the password respects the system's password policy.

You can get back in the same way you would if you lost the administrator password under any other conditions.

If you have an administrator account, and it's not the account you specified as <username>, you can get it back by changing the password in the usual way:

sudo passwd <username>
1
  • Thanks for the help! Apparently I should have looked harder for how to get back in after losing administrator pw, but maybe this will be a good link for anyone who made the same mistake I did. Jan 11, 2013 at 23:49
2

From man usermod:

   -p, --password PASSWORD
       The encrypted password, as returned by crypt(3).

       Note: This option is not recommended because the password (or encrypted password) will be visible by users listing the processes.

       The password will be written in the local /etc/passwd or /etc/shadow file. This might differ from the password database configured
       in your PAM configuration.

       You should make sure the password respects the system's password policy.

which basically means that the -p option needs a pre-encrypted password hash, not the actual value you're typing when logging in. This is a rarely-used option.

The recommended way to change your password from command line is to use passwd command.

To fix things, now you need to boot into recovery mode, log in as root and change your password using passwd username

1
  • Thanks Sergey, I tried this and it almost worked but my system was in read-only mode. I had to follow the instructions from the link in Eliah's answer to finish changing the password. Solid answer though, helped a lot! Jan 12, 2013 at 1:22
0

If you have root permissions you can enter

sudo passwd loginname

The command will change the password of this specific user. After that you are able to log in again.

2
  • The OP can't log in...
    – Sergey
    Jan 11, 2013 at 23:25
  • @Sergey The question doesn't specify if the problem is the OP cannot log in as that user, or cannot use the system at all. I think this is a reasonable answer. Jan 11, 2013 at 23:26

You must log in to answer this question.

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