USA Linux Users Group Forum Index
Log in Register FAQ Memberlist Search USA Linux Users Group Forum Index Album

Recovering from a lost root password
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic   printer-friendly view    USA Linux Users Group Forum Index » System Administration and Security
View previous topic :: View next topic  
Author Message
geeshock
Moderator


Joined: 02 Nov 2024
Posts: 1017
Location: Hertford, NC

PostPosted: Sat Apr 23, 2024 10:58 pm    Post subject: Reply with quote

now again this is provided you haven't encrypted the root partition of your HD Smile. Hey it could happen


Back to top
View user's profile Send private message Visit poster's website AIM Address
lynch
Moderator


Joined: 15 Nov 2024
Posts: 2659
Location: The Diamond State

PostPosted: Sat Apr 23, 2024 11:13 pm    Post subject: Reply with quote

I setup a grub password on my laptop to test the stuff I wrote in my password protection post and I forgot it afterwards. Then I remembered where I wrote it down in my notes. Smile
lynch



_________________
Mandriva 2024 Spring -2.6.31.12-server-2mnb
PCLinuxOS 2024 -2.6.26.8.tex3
Back to top
View user's profile Send private message
mushroom
Ultimate Member


Joined: 29 Jun 2024
Posts: 2129
Location: Queen Charlotte B. C. Canada

PostPosted: Wed Jun 15, 2024 4:40 am    Post subject: Reply with quote

I had friend who set up a couple of other friends with SuSE and did not tell them the root password so they could not mess it up.
He died a year and a half ago. Crying or Very sad

Now one of them needs configuration changes within a week or he will have no internet.

Glad this tread was here, even if it did not work on SuSE (tested on 9.3), went to few other forums and tried their solutions none of which worked Embarassed

After 8-10 hrs of searching and testing and almost ready to give up had an idea

Why worry about blanking the password and putting in a new one, just replace it with one I know Idea Idea Idea

1. Go to a working SuSE box that I know the root password of, open "/etc/shadow" and copy the complete line that starts with "root:" to a text file and save it to a floppy.
2. Go to the "lost root password" box with a live CD (I used Mepis) and boot from the live from the CD.
3. Login as root, mount the hard drive and the floppy
4. Open the text file in a text editor and copy the line to the clipboard
5. Open "/etc/shadow" in a text editor and replace the "root:" line with the one in the clipboard, save it and your done. Smile Smile Smile

Tested the same string on 8.2, 9.2, and 9.3, all worked



_________________
SuSE 8.0, 8.2, 9.0, 9.1, 9.2, 9.3, 10.0, 10.1, 10.2, 10.3, 11.0, 11.1
Live CDs Mepis 8.0, Puppy 4.3.1, netbook- Zenwalk 6.2
Back to top
View user's profile Send private message Visit poster's website
jbsnake
Moderator


Joined: 02 Dec 2024
Posts: 1726
Location: Georgia

PostPosted: Wed Jun 15, 2024 6:18 am    Post subject: Reply with quote

mushroom wrote:

Why worry about blanking the password and putting in a new one, just replace it with one I know Idea Idea Idea


or you could just create a new one
Code:

openssl passwd -1 "new password"

whatever gets spit out is what you would paste on the line for root
in the shadow file "/etc/shadow"
the first (IIRC) line will be the one for root
it will look something like
Quote:

root:$4$F14.FJyn$OgGPJWcJPpDpzZGaTvwtl1:12989::::::

i would leave everything as it is except the second field
i.e. root:<from here to............................................here>:12989::::::
Quote:

$4$F14.FJyn$OgGPJWcJPpDpzZGaTvwtl1

is our encrypted password
if you paste what you get from the line of code from above
"new password" will be your password for root
ofcourse actually mounting and writing to the disk is the tricky part (not really since everyone has a live cd now-a-days Wink )
but that's how you can do it without knowing another password Smile



_________________
laptop: Arch Linux - Kernel 2.6.24-ARCH
server: Arch Linux - Kernel 2.6.33-ARCH
Back to top
View user's profile Send private message
jbsnake
Moderator


Joined: 02 Dec 2024
Posts: 1726
Location: Georgia

PostPosted: Wed Jun 15, 2024 6:22 am    Post subject: Reply with quote

infact...i just remembered...
i think i had this written in a class i had that used linux machines and everyone forgot root at one point or another
Quote:

<- jb:/home/jbsnake/scripts -> openssl passwd -1 "temporary"
$1$Ymlk/Q3g$dNq.UC7owF4qnBxvIZQrQ/

we would just paste
$1$Ymlk/Q3g$dNq.UC7owF4qnBxvIZQrQ/
into the space for the root password...that way everyone had "temporary" as their password if they goofed...atleast until they changed it the next log in Smile



_________________
laptop: Arch Linux - Kernel 2.6.24-ARCH
server: Arch Linux - Kernel 2.6.33-ARCH
Back to top
View user's profile Send private message
nukes
Linux Guru


Joined: 29 Aug 2024
Posts: 4558

PostPosted: Thu Jun 16, 2024 6:13 pm    Post subject: Reply with quote

Some systems will still prompt for a password in single-user mode. You can circumvent this by passing
Code:
init=/bin/bash

to the kernel command line, then mounting everything and changing the password.



_________________
Gentoo x86-64 2.6.29.1
FreeBSD 7-CURRENT
Arch x86 2.6.30
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Merlin615
Member


Joined: 17 Sep 2024
Posts: 149
Location: Elk Mound, WI

PostPosted: Sun Jun 26, 2024 6:41 pm    Post subject: Reply with quote

Well folks it happened to me, however my computer crashed while I was out to sea from a power outage, my wife was able to logon but that was the last time any of us were able to login. So I think i'm gonna use P.H.L.A.K. to get in and change the root password and go from there. I wonder why it lost all the passwords in the first place.... Confused



_________________
Arch Kernel 2.6.19-3
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
JP
Linux Guru


Joined: 07 Jul 2024
Posts: 6670
Location: Central Montana

PostPosted: Sun Nov 13, 2024 10:38 pm    Post subject: Reply with quote

Crouse, I didn't have a choice for single user mode in this RedHat 8.0, so I tried to recover the passwlrd your way. These are the results:
Code:
knoppix@ttyp0[knoppix]$ /mnt/hda2
bash: /mnt/hda2: is a directory
knoppix@ttyp0[knoppix]$ chroot /mnt/hda2
chroot: cannot change root directory to /mnt/hda2: Operation not permitted
knoppix@ttyp0[knoppix]$ passwd
Changing password for knoppix
(current) UNIX password:
Code:
knoppix@ttyp0[knoppix]$ su
root@ttyp0[knoppix]# /mnt/hda2
bash: /mnt/hda2: is a directory
root@ttyp0[knoppix]# chroot /mnt/hda2
chroot: /bin/bash: No such file or directory
root@ttyp0[knoppix]# passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
root@ttyp0[knoppix]#

Niether of these works!
This is the hard drive out of Paul's computer and I am trying to get into the RedHat without damaging the Windoze (where he did a lot of his Poser/Bryce/Carrerra/Macromedia Flash stuff.



_________________
Dell Box - Arch Linux
Dell Lappy - DreamLinux 3.5 - Default OS
Mepis 8.0 - Backup
Back to top
View user's profile Send private message Visit poster's website
Germ
Keeper of the BIG STICK


Joined: 30 Apr 2024
Posts: 12452
Location: Planet Earth

PostPosted: Sun Nov 13, 2024 11:35 pm    Post subject: Reply with quote

Check this out:
http://www.redhat.com/docs/manuals/enterprise/RHEL-3-Manual/step-guide/s1-q-and-a-linux-single.html

Should work the same for RH 8.


EDIT: found something else...RH 8.0 manuals

http://www.redhat.com/docs/manuals/linux/RHL-8.0-Manual/



_________________
Laptop: Mandriva 2024 PowerPack - 2.6.33.5-0.2mnb
Desktop: Mandriva 2024 Free - kernel 2.6.33.2-1mib
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
JP
Linux Guru


Joined: 07 Jul 2024
Posts: 6670
Location: Central Montana

PostPosted: Mon Nov 14, 2024 1:09 am    Post subject: Reply with quote

Thanks Germ, that one in the enterprise worked like a champ! Couldn't find the same one in the RH9 docs, so I'm glad you found the other. There was some good Grub/LILO stuff in the RH8, so I copied and pasted and printed it off;) Very Happy Very Happy



_________________
Dell Box - Arch Linux
Dell Lappy - DreamLinux 3.5 - Default OS
Mepis 8.0 - Backup
Back to top
View user's profile Send private message Visit poster's website
Cope57
Sr. Member


Joined: 25 Jan 2024
Posts: 1602
Location: 34.638673, -98.384704

PostPosted: Mon Nov 14, 2024 4:02 am    Post subject: Reply with quote

Merlin615 wrote:
I wonder why it lost all the passwords in the first place.... Confused

Possible motherboard CMOS battery went dead?



_________________
This block is for DISTRO information ONLY, all other information will be removed by the Site Administrators.
Debian GNU/Linux testing - Linux 2.6.32-4-amd64
Back to top
View user's profile Send private message Visit poster's website
Germ
Keeper of the BIG STICK


Joined: 30 Apr 2024
Posts: 12452
Location: Planet Earth

PostPosted: Mon Nov 14, 2024 12:28 pm    Post subject: Reply with quote

JP wrote:
Thanks Germ...


My pleasure. Smile



_________________
Laptop: Mandriva 2024 PowerPack - 2.6.33.5-0.2mnb
Desktop: Mandriva 2024 Free - kernel 2.6.33.2-1mib
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
flashingcurser
Member


Joined: 13 Sep 2024
Posts: 134
Location: Montana

PostPosted: Tue Dec 13, 2024 11:01 pm    Post subject: Reply with quote

Variant of the same walk through--

Boot with a slackware install cd (from 8.0 to 10.2 will do)-- it takes you directly to a command line. (Just dont type in "setup" and most of the time the stock kernel works)

mkdir /whatever
mount /dev/hda /whatever (most of the time you dont have to put "-t fstype")
chroot /whatever
/usr/sbin/passwd root

dan



_________________
True64, Slack, OpenVMS, Debian, etc..
Back to top
View user's profile Send private message Send e-mail Visit poster's website
JP
Linux Guru


Joined: 07 Jul 2024
Posts: 6670
Location: Central Montana

PostPosted: Wed Dec 14, 2024 6:41 am    Post subject: Reply with quote

Just thought I'd add this which I found on the Libranet forum:
Lunarglow wrote:
The following belongs in every Linux user's bag of tricks. Basicallly, if you can physically get to the computer, you can reset the root password, UNLESS the BIOS has been password protected, or unless the boot manager has been passward protected.

If you're using Libranet, let the computer boot to the GRUB menu. Then, press e (for edit) before Linux has a chance to boot.

Now, cursor down a line, and press e (for edit) again, you should now be on the kernel line, and press End to go out to the very end of that line. Now add the folllowing:

Code:

init=/bin/bash



or you could enter,

Code:

init=/bin/sh



All you're doing is, telling Linux to boot to a console shell instead of running all the startup programs, which are defined in /etc/init.d

Now, press Enter, and you're back at the kernel line, press b (for boot) and the computer will proceed to boot to a prompt.

At this point, the root file system is still mounted read-only, so enter the following command:

Code:

mount -n -o remount,rw /



The above is not magic, all it is, the -n tells the command Not to add the setting to /etc/mtab (which, at the moment, it CAN'T, because it's still read-only), and the -o says, here comes some Options, which are remount,rw (re-mount as read-write) the / (root file system).

Now you're IN !!!

Other tutorials give more complicated instructions, but all you really have to do now is,

Code:

passwd



and proceed to create the new password.

After this, just go

Code:

reboot



And you're done. When the O.S. boots up, you can log in as root using the new password.


And then this, just in case *crosses fingers*
cyphedude wrote:
lunarglow wrote:

...UNLESS the BIOS has been password protected...



Actually, most (if not all) motherboards have a jumper that can reset the BIOS settings back to default, which erases the password. A BIOS password is useless unless you physically block access to the motherboard.


I think it's pretty newbie friendly in it's explanation Very Happy Very Happy



_________________
Dell Box - Arch Linux
Dell Lappy - DreamLinux 3.5 - Default OS
Mepis 8.0 - Backup
Back to top
View user's profile Send private message Visit poster's website
jbsnake
Moderator


Joined: 02 Dec 2024
Posts: 1726
Location: Georgia

PostPosted: Wed Dec 14, 2024 2:02 pm    Post subject: Reply with quote

ofcourse... on the above you are relying on the fact that there is pause time during the lilo or grub boot menu. my system has no such thing (i like to turn on the computer and be able to walk away)
and ofcourse if there is no "pause time" then you can't press 'e' to edit in grub, or pass commands to lilo Smile



_________________
laptop: Arch Linux - Kernel 2.6.24-ARCH
server: Arch Linux - Kernel 2.6.33-ARCH
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    USA Linux Users Group Forum Index » System Administration and Security All times are GMT
Goto page Previous  1, 2, 3, 4  Next
Page 2 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All content © 2024-2009 - Usa Linux Users Group
This forum is powered by phpBB. © 2024-2009 phpBB Group
Theme created by phpBBStyles.com and modified by Crouse