How to enter the Linux machine without root password
If the linux box's password has changed and it is not possible to loggin, you will need some hacking techniques to go into the linux machine.
The first method is easier and may be possible if you have single user mode enabled in grub.
At grub boot prompt write:
> linux single
Then it will bood in user single mode, runlevel 1, at this point you can just run "passwd root" and change the password.
The advanced technique is, editing the grub kernel boot parameters, press "e" at grub, and add to the kernel options "init=/bin/sh". Then press "b" to boot with that kernel. A command prompt will appear, the linux partition is mounted at this moment read only.
Write:
$ mount / -o remount,rw
Now you can write to the partition and this way edit your password if you loosed it.
How to secure the grub boot loader ?
To secure grub and prevent to enter the machine without a password, letting on a side the fact that you have to physicaly secure the machine (disable cd, floppy,usb,etc), you would want to configure a password for grub:
[root@serverlinux ~]# grub-md5-crypt Password: Retype password: $1$4shhF$MFIg6cjkfUwQYyhA8ZgRH0
Edit /boot/grub/menu.lst and add the password hash that grub-md5-crypt created:
default 0
timeout 5 password --md5 $1$4shhF$MFIg6cjkfUwQYyhA8ZgRH0
title Linux serverlinux.blogspot.com 2.6.22.9-61.fc6 root (hd0,0) kernel /boot/vmlinuz root=/dev/hda3 ro savedefault boot
Friday, October 2, 2009
Subscribe to:
Post Comments (Atom)
Please post a link back to serverlinux.blogspot.com because i am the original author of this article. Thanks.
ReplyDelete