I lost my password to a VM running 11.04, but have ssh access via public key authentication.

Is there any way I can reset the password without a reboot? (This is to avoid downtime of services it's running.)


You can if you:

  • know a root password, do su - and enter root password.

    But authenticating directly as the root account is disabled by default (and unsupported, though possible) in Ubuntu, so you may not be able to do this.

  • have sudo access without password, do sudo passwd youruser.

  • can log in to another administrative account, and then use sudo in that account to change the password for your first account.

  • can perform actions with PolicyKit (e.g., via psexec) without entering your password. This is very unlikely, but it's easy to try. Try psexec passwd youruser.

Basically you need to get root access somehow.

If you have access to VM console you have root permissions there (e.g. for XEN: xm console vm-name).

Theoretically at least, you could make a copy of the VM, mount the drive of the (non-running) copy, dump the password hashes from /etc/shadow, and crack them, to discover your password. If you remember some things about your password, then a good password cracking program (which tend to be proprietary payware) should be able to use that information to avoid checking for passwords that can't be it.

But unless your password is really simple, or you know a lot about it and are experienced dumping and cracking password hashes, and also unless the need to avoid downtime is extreme, you should not attempt something like this. (In fact, I mainly bring it up for completeness, so you can see that the reasonable options really have been exhausted.) Instead, if you cannot become root in the VM and you cannot use the VM console, you should just reboot the VM, boot into recovery mode, and reset the password.

  • no, i don't have some other root password. any other way to avoid a reboot? – GJ. May 24 '12 at 13:52
  • @GJ., have you tried VM console? – Paweł Nadolski May 24 '12 at 14:01
  • @GJ. I've edited the answer to include information on two other methods, but it is pretty much true to say that there is not any other way to avoid a reboot. – Eliah Kagan May 24 '12 at 14:24
  • @PawełNadolski I'm using Parallels Desktop - I don't seem to find any evidence of a "console" feature there. – GJ. May 24 '12 at 14:41

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.