Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
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 Jul 28 '10 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 Jul 28 '10 at 12:42
add comment

2 Answers

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

share|improve this answer
add comment

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

share|improve this answer
    
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  
Typo! Try chroot /mnt/root passwd –  Craig Jul 30 '10 at 20:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.