Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers 3

up vote 3 down vote accepted

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>
share|improve this answer
    
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. –  Andrew Coomes Jan 11 '13 at 23:49
add comment

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

share|improve this answer
    
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! –  Andrew Coomes Jan 12 '13 at 1:22
add comment

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.

share|improve this answer
    
The OP can't log in... –  Sergey Jan 11 '13 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. –  Eliah Kagan Jan 11 '13 at 23:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.