How to reset my password without rebooting?

5,555

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.

Share:
5,555

Related videos on Youtube

GJ.
Author by

GJ.

Updated on September 18, 2022

Comments

  • GJ.
    GJ. over 1 year

    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.)

  • GJ.
    GJ. almost 12 years
    no, i don't have some other root password. any other way to avoid a reboot?
  • LarsH
    LarsH almost 12 years
    @GJ., have you tried VM console?
  • Eliah Kagan
    Eliah Kagan almost 12 years
    @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.
  • GJ.
    GJ. almost 12 years
    @PawełNadolski I'm using Parallels Desktop - I don't seem to find any evidence of a "console" feature there.