Advanced

Nothin new here...

Story: Using chroot to Recover root PasswordsTotal Replies: 9
Author Content
techiem2

Jun 03, 2008
2:54 PM EDT
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.
obsidianreq

Jun 03, 2008
10:34 PM EDT
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".
Bob_Robertson

Jun 04, 2008
3:25 AM EDT
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.
rijelkentaurus

Jun 04, 2008
3:44 AM EDT
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.
rgviza

Jun 04, 2008
6:56 AM EDT
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...
gus3

Jun 04, 2008
7:45 AM EDT
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.
rijelkentaurus

Jun 04, 2008
8:01 AM EDT
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.
jdixon

Jun 04, 2008
9:02 AM EDT
> 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.
gus3

Jun 04, 2008
9:17 AM EDT
And if you don't have a working Slackware CD handy? (it got scratched when I wasn't looking)
jdixon

Jun 04, 2008
10:45 AM EDT
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 reply to this thread:

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:
|||||
10
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