2

I have a dedicated server that i've just setup at Hetzner. I've done the stupid thing of not changing the temp password they give you and disconnected from the SSH session. They don't send nor store this password so it's lost.

I need to reset it.

I'm on a 64-bit Ubuntu install and with a software raid. I reboot into the rescue routine and run the following;

ls /dev/md*

Which displays the 4 partitions of md0, md1, md2, md3

I then mount the boot drive with mount /dev/md2 /mnt. I prepare and try to switch into chroot with the following commands.

chroot-prepare /mnt
chroot /mnt

With the last command i get the output of: mkdir: cannot create directory ‘/mnt/run/lock’: File exists

I then change the password with passwd root. This all accepts the commands, i reboot and the password still doesn't work.

Nathan
  • 165
  • 8
  • rightliy or wrongly i deleted the lock directory in the rescue image, this allowed the commands to run cleanly. Once again, after reboot i still can't get in – Nathan Jun 04 '19 at 18:37
  • At this point, it's likely faster to just reinstall the whole server again... – Sven Jun 04 '19 at 19:31
  • 1
    Did you try to edit a boot command? reboot Ubuntu, then press E to edit the boot parameters, find the line starting with "linux" and append *rw init=/bin/bash" at the end of line. And press Ctrl + X to boot. Now type passwd root, and reboot. Your new password should work. – tien Jun 05 '19 at 10:34
  • At this point i do not have access to boot into grub. i can only initiate a reboot into their rescue runtime via their web control panel. – Nathan Jun 06 '19 at 09:42
  • Is there a way to do it via config files as i can get access to the drive and make changes – Nathan Jun 06 '19 at 11:11

1 Answers1

0

I just had to do the exact same thing on Hetzner and I can give the precise solution for this specific case:

The command that returns an error (chroot-prepare /mnt) it's not really necessary!

You can do:

chroot /mnt

Without errors, and then do:

passwd

I tested it and the password was successfully reseted.

Michael Rogers
  • 60
  • 1
  • 3
  • 16