Using chroot to Recover root Passwords
|
|
|
Comments (10)
I suspect most of us have known this for ages and have used it to "fix" lost root passwords (of our own or other systems).
Though I don't generally go through all the mounting proc and dev and such to the chroot to do it.
Mounting /dev and /proc are just to ensure system integrity in the new environment.
Of course, this whole article goes in to the "physical access to a machine is total access to a machine".
Of course, this whole article goes in to the "physical access to a machine is total access to a machine".
I may be the only person who has never knowingly used chroot.
Boot a live CD and delete the encoded password from /etc/shadow, /etc/password, or where ever it is.
Then just change the password normally as soon as the machine is restarted, network disconnected.
People do need to grasp that physical access _is_ complete access, and learn strong encryption and effective back-up methods.
Boot a live CD and delete the encoded password from /etc/shadow, /etc/password, or where ever it is.
Then just change the password normally as soon as the machine is restarted, network disconnected.
People do need to grasp that physical access _is_ complete access, and learn strong encryption and effective back-up methods.
Or boot with a live cd, change the /etc/inittab to runlevel 1, and reboot. Or change to runlevel 1 at the GRUB prompt, etc. There are other ways, not that this way isn't a good one to have in the bag.
Then again, downloading and burning a live cd isn't even always necessary. Some linux distros will have a single user mode option on their installation cd. Just pop it in (even a very old one), boot to rescue mode, chroot /mnt/sysimage (or wherever it mounts the existing drive) and reset password.
@obsidianreq yep...
@obsidianreq yep...
Defaulting to runlevel 1 doesn't work in Slackware, as the system will still use agetty logins. You must bypass init with
init=/bin/sh
on the kernel boot command line. (This is if you can boot the -huge kernel. I haven't done this with a -generic kernel and initrd.) Once you get your shell prompt, remount the root partition read-write with
mount -o remount,rw /dev/XXXX /
and then you can change your password. Remount root read-only (change "rw" to "ro" above) and reboot.
init=/bin/sh
on the kernel boot command line. (This is if you can boot the -huge kernel. I haven't done this with a -generic kernel and initrd.) Once you get your shell prompt, remount the root partition read-write with
mount -o remount,rw /dev/XXXX /
and then you can change your password. Remount root read-only (change "rw" to "ro" above) and reboot.
Good to know about Slackware, I have already noticed that some of the commands I am used to don't work, most notably ifup and ifdown (as I have read, it would be ifconfig eth0 up/down). Just something else to get used to, I really like how fast this system is.
> Defaulting to runlevel 1 doesn't work in Slackware, as the system will still use agetty logins.
Yes. Runlevel 1 is single user mode, but it still uses the login process. The Slackware install CD/DVD will let you mount your root partition and reset your password though, as noted above for other install CD's.
Yes. Runlevel 1 is single user mode, but it still uses the login process. The Slackware install CD/DVD will let you mount your root partition and reset your password though, as noted above for other install CD's.
And if you don't have a working Slackware CD handy? (it got scratched when I wasn't looking)
Well, as noted above, pretty much any install CD or live CD will work. You don't keep any live CD's around?
Post a comment
A free account is needed to post. Write your comment here first: your text is kept in this browser while you sign up or log in, and is waiting for you when you come back.
Your message:Markdown: **bold**, *italic*, [text](https://link), - lists, > quotes, $x^2$ for math. Formatting help
Sign up and post (it is free) or Log in and post
