5

I lost/forgot the root password to a server sitting beside me and am trying to reset it. I would rather not have to wipe and re-install or use a Live CD (server is running Ubuntu Server 12.04). What I've tried so far...

1) Boot into "Recovery mode" from Grub2 boot menu then drop into root shell prompt. I am prompted to "Give root password for maintenance". No-go.

2) Change the boot parameters for the main boot option to include "rw" and "init=/bin/bash". When I then boot with Ctrl-X, the screen goes black, and nothing happens (I've waited five minutes). init=/bin/sh and init=/bin/static-sh both do the same thing, while init=/sbin/init boots as normal.

Is there anything else I can try to reset the root password? Thank you!

Albeit
  • 161
  • 1
  • 1
  • 2
  • 1
    If you would have left Ubuntu with the standard configuration, then root would have a disabled password, and you would have gotten a menu you when you went into recovery mode. Did you also forget the password for the first account that had sudo access? – Zoredache Nov 30 '12 at 17:43
  • Have you considered using sudo that way you would not need to use the root password all the time? – mdpc Nov 30 '12 at 18:11
  • Thank you all for helping me. I ended up with a clean debian re-installation. I now have to reinstall apache and other software from scratch again. – Penge58 Jun 21 '21 at 19:45
  • Does this answer your question? [Lost Root and other user passwords](https://serverfault.com/questions/132837/lost-root-and-other-user-passwords) – djdomi Jun 22 '21 at 04:43
  • By the way booting a live boot medium would fix your issue, since you can edit then the /etc/password and remoe the password marker to get a password less root this is how i do – djdomi Jun 22 '21 at 04:45

2 Answers2

10

If you're already rebooting, just boot into the Live CD, chroot into the server's root filesystem, and run passwd. Problem solved.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
1

I just tried on a near-blank Ubuntu server 12.04 in Virtualbox. Holding SHIFT down while booting, choosing the first entry, pressin "e" to edit, I replace

ro quiet

with

rw nosplash boot=/bin/bash

and it boots up without problems into a bash-shell. Perhaps the graphic-cards is making you trouble, thus the nosplash.

ineiti
  • 111
  • 2
  • OMG, its taken me hours to find how to interact with a VM during boot. I'm using an Ubuntu cloud image that uses cloud-init which changes passwords. I tried inserting kernel args with `vboxmanage setextradata` but it doenst allow `init=/bin/bash`. Thank you for this! – alchemy Nov 20 '21 at 02:34
  • Wow, I forgot that was a grub thing. I think I only used that once ages ago because I use AIOBOOT which allows editing grub boot commands. – alchemy Nov 20 '21 at 04:49