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?
Asked
Active
Viewed 1.0k times
5
-
1The 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 Jul 28 '10 at 12:24
-
1While 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 Jul 28 '10 at 12:42
2 Answers
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

Craig
- 570
- 4
- 13
-
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 Jul 28 '10 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 Jul 28 '10 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 Jul 28 '10 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 Jul 28 '10 at 14:52
-
1
6
While Craig's answer will definitely work, I discovered the following also works:
- Hit the reset button and immediately click into the Virtual Machine Connection window so that it grabs the keystrokes.
- 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...

Colin Pickard
- 1,260
- 2
- 16
- 28
-
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 Jan 28 '21 at 18:53