5

I have a virtual Ubuntu 10.04 machine running under Hyper-V which I have lost the password to. With a physical Ubuntu box it's rather easy to press ESC at the grub prompt and proceed to reset your password. Unfortunately I can't see a grub menu and pressing ESC does nothing. Can anyone offer some advice for how to reset the password on this virtual machine?

2
  • 1
    The fact that it's a virtual machine makes no difference. ESC works just the same when you have the console window up; perhaps pushing it rapidly would work, I don't think the Hyper-V BIOS passes any key presses during BIOS initialization.
    – Chris S
    Commented Jul 28, 2010 at 12:24
  • 1
    While I agree that it makes no difference that it's a VM, Hyper-V not passing keypresses during bios init. is definitely a huge problem and it appears that this is the case.
    – JohnyD
    Commented Jul 28, 2010 at 12:42

2 Answers 2

6

Use a boot cd! - mount your root partition to /mnt/root/ - change /etc/shadow to root::[and so on] - OR type: "chroot /mnt/root passwd" - reboot, login with empty password or the new one you specified

5
  • Could you explain those steps a little more? How do I mount my root partition to /mnt/root/? By boot cd I assume you mean an Ubuntu 10.04 cd?
    – JohnyD
    Commented Jul 28, 2010 at 12:47
  • Use a grml or gentoo boot (aka "Live)-CD. I don't know your partition layout, so try: mount /dev/sda /mnt/root
    – Craig
    Commented Jul 28, 2010 at 13:27
  • Ok, I've booted my GRML live cd. I create a directory 'root' in /mnt/. I successfully 'mount /dev/sda1 /mnt/root'. After this I: 'nano /etc/shadow' and can see my account name and the hashed password within it. I remove everything between the ::'s. When I reboot as soon as I press enter on my username it says 'Authentication Failure', it does not even ask for a password. I restored my vhd and tried again, this time placing an '!' in /etc/shadow for my user account which should be interpreted as NULL or blank...
    – JohnyD
    Commented Jul 28, 2010 at 14:52
  • ...This time when I rebooted it allowed me to enter a password but it gave me an Authentication Failure when I tried a blank pass. Also, 'chroot /mnt/root pass' gave me an error because pass is not a command. I used passwd and it gives me, "Authentication token manipulation error. Password unchanged." Any suggestions?
    – JohnyD
    Commented Jul 28, 2010 at 14:52
  • 1
    Typo! Try chroot /mnt/root passwd
    – Craig
    Commented Jul 30, 2010 at 20:43
6

While Craig's answer will definitely work, I discovered the following also works:

  1. Hit the reset button and immediately click into the Virtual Machine Connection window so that it grabs the keystrokes.
  2. Frantically hammer both shift keys and the ESC key while until you get a GRUB menu.

Apparently holding down the shift key or pressing it in a less manic fashion is not enough, as the window of opportunity is very small...

1
  • Love this highly scientific answer :). One problem I found is that Windows wants to turn on Sticky Keys if you press Shift five times in a row. I disabled that under Ease of Access. Alas, no amount of frantic hammering would make it stop at the grub loader. I guess it's on to try a live CD. (BTW this was with Ubuntu 18.04 and Hyper-V on Server 2016.)
    – Mark Berry
    Commented Jan 28, 2021 at 18:53

You must log in to answer this question.

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