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.)
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
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.
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.