1748117 Members
3741 Online
108758 Solutions
New Discussion юеВ

Re: Password Retrieval

 
SOLVED
Go to solution
Francis Ancheta
Frequent Advisor

Password Retrieval

How do I retrieve a lost password in Redhat 8.0. My Linux system in now stable with routing/proxy and mail and I do not want to re-install my system just because I was clumpsy not to jot down the password of the server.

Is there a way I can retrieve my root password?
10 REPLIES 10
Steven E. Protter
Exalted Contributor
Solution

Re: Password Retrieval

Okay, you are in deep trouble.

On an HP-UX system with a console, you can boot into single user mode, sometimes with the power switch, and null out the password entry in the shadowed password file.

Here is how to do it in Linux.

Here are 3 methods :

1. The easiest one : reboot your system in single-user mode, cancel the root password, and reboot normally to set another one.

To boot single-user, at LILO prompt type "linux s".

Some Linux distributions require root password to enter single-user. If it is your case, try the second method.

2. The most difficult one : reboot your system with a recovery CD-Rom or disk, mount the root filesystem and cancel the password.

It is not so difficult, but you need some Linux expertise. Just to summarize : boot on the Install CD just as if you wanted to re-install, go through the steps until keyboard and language selection, then type CTRL-ALT-F2 to open a shell.
Then :

mkdir /new
mount /dev/your_root_partition /new
/new/usr/bin/vi /new/etc/passwd

Clear the password field.

Then, umount the root partition :

umount /new

To reboot : remove the install CD-Rom and/or floppy, then CTRL-ALT-DEL.


This is Red Hat 7. They might have made things tighter.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Steven E. Protter
Exalted Contributor

Re: Password Retrieval

I was rude.

I should have given the thread I stole that from.

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xcfebff77de2bd611abd50090277a778c,00.html

I consider this a solution. Just tested it. Seems to work Red Hat 9.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Francis Ancheta
Frequent Advisor

Re: Password Retrieval

How do I boot in single user mode? I think I just created a rule in my firewall that stops logging in in single user mode ... but anyway I will try it.
Steven E. Protter
Exalted Contributor

Re: Password Retrieval

Interupt the boot of the Linux server at its keyboard

That is usually with a keystroke.

linux s



If you can't be on site, you need to get an operator on the keyboard of the server.

I hope this provides you with a solution.

I'll check on the thread in the morning.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Jerome Henry
Honored Contributor

Re: Password Retrieval

Adding to Steven's tip :

If your boot loader is grub, then, on seing grub screen with your systems listed, highlight the one you boot (if you have only one system, then you see only one line !), then press 'e' to edit it. You see several lines with one being the longest, referencing the kernel you boot. At the end of this line, insert ' single' (notice 'space single'), then enter to validate, then 'b' to boot with this option. You'll boot to a shell. Enter 'passwd root'(enter), then enter twice the new root password. Reboot. You are done.

If your boot loader is lilo, then on lilo screen, depending on your distro, pressing 'escape', or 'Ctrl C' or 's' or 'Ctrl X' bring you to a dark screen... where you see 'boot :' type 'linux single' (enter), you boot to a shell. Then same 'passwd root' procedure as above.

hth

J
You can lean only on what resists you...
Caesar_3
Esteemed Contributor

Re: Password Retrieval

Hello!

If you forgot the password you just only
can to change it to new one (if you want to
know the old it can take a lot of time if you will use program like "john the ripper" that brutforce the passwords)

So you need to enter single mode:
lilo -> lilo single
grub -> press "e" to edit the boot line
then "e" for edit the line of kernel boot,
add in the end of line "single" press enter and
"b" for boot

You will enter the single mode then change the
password.

Caesar
Francis Ancheta
Frequent Advisor

Re: Password Retrieval

Thanks for the response. Before I left this server I configured the firewall and I made sure that no one can boot at single mode.

I tried booting at single mode but it still looks for a password. I haven't re-installed yet but I am thinking of removing the disk and puting it in another linux box ... mount it and edit the password file. Will this work?
Vitaly Karasik_1
Honored Contributor

Re: Password Retrieval

yes, it will work (don't forget about /etc/shadow)

but you can do the same thing using rescue mode from RH installation CD


Regards,
Vitaly
Francis Ancheta
Frequent Advisor

Re: Password Retrieval

I was able to change it ... thanks guys ... I placed the disk in my other server ... it took me 10 min. to accomplish the task.

I was a bit hesitant to do a restore thinking that some of my system files that I have updated through my upgrades might be overwritten.

I will try to experiment with one of my none production servers. Thanks again.