How Do I Reset The Root Password?


Cervante

PS3 ID: Cervante1
Joined
Jun 28, 2006
Messages
573
Location
SD card slot
Website
Visit site
I got a replacement usb cable, then started to telnet the gp2x, logged in as root, changed the pass and now I forgot the pass :( ...what do I do now?
 
Cervante posted on Mar 3 2007 at 01:07 AM said:
I got a replacement usb cable, then started to telnet the gp2x, logged in as root, changed the pass and now I forgot the pass :( ...what do I do now?
Opps.

Are you still logged in?

If so, do this:

cd /etc
vi passwd

press the l (L but just press the key) key repeatedly until you get to the below, make sure the cursor is after the :

root:<some shit>:0:0 <etc>

remove the crap by pressing x until it looks like this :

Code:
root::0:0:root:/root:/bin/sh

IF YOU MAKE A MISTAKE PRESS escape a few times ON YOUR KEYBOARD and type :q! <ENTER KEY>

Warning I am drunk!
 
Last edited by a moderator:
Cervante posted on Mar 3 2007 at 01:42 AM said:
no i am not logged in anymore... :(

Why do these things happen when I'm so drunk (not to mention when I have a pizza in the oven) :(

OK, what firmware version are you running?

I think things (/etc/passwd) should look like this:

Code:
max@vila:~> telnet gp2x
Trying 10.1.0.1...
Connected to gp2x.
Escape character is '^]'.

Linux 2.4.25 (gp2x) (ttyp0)


gp2x login: root
[root@gp2x root]$cat /etc/passwd
root::0:0:root:/root:/bin/sh
bin:x:1:1:bin:/bin:
daemon:x:2:2:daemon:/sbin:
adm:x:3:4:adm:/var/adm:
lp:x:4:7:lp:/var/spool/lpd:
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:
news:x:9:13:news:/var/spool/news:
uucp:x:10:14:uucp:/var/spool/uucp:
operator:x:11:0:operator:/root:
games:x:12:100:games:/usr/games:
gopher:x:13:30:gopher:/usr/lib/gopher-data:
ftp:x:14:50:FTP User:/home/ftp:
nobody:x:99:99:Nobody:/:

So, we want the first line to change back to this "root::0:0:root:/root:/bin/sh". But, I'm going to have to remember how to use SED to fix it... Does the thing boot up? Do you get to the GPH menu? If it does we can either brick it, or fix it with a script :)
 
Last edited by a moderator:
OK, this should hopefully do it (run at own risk)! Copy the following to a file and save on the SD card. Then run from the menu:

Code:
<see below> (hardwired path here - god am I a kiddie today...)

It will change to the /etc directory, make a copy of the passwd file, delete the root user account entry (bad), and then recreate everything (it has to be this way because sed in busybox wont honor s/).

Hope this works! (I've tested it a few times, but you may want to wait and see if the gurus here think it will work first!)

Cervante posted on Mar 3 2007 at 02:46 AM said:
the FW im running is 3.0
But I've tested this on firmware 2...
 
Last edited by a moderator:
Of course, by the above I mean this:

Code:
#! /bin/sh
cd /etc
cp passwd passwd_dave
sed '/^root/d' passwd > passwd_fix
if [ -f passwd_fix ]; then
		echo "root::0:0:root:/root:/bin/sh" > passwd
		cat passwd_fix >> passwd
fi
exec /usr/gp2x/gp2xmenu

Edit: This replaces the removed one above.
 
You could either reflash 2.0 or play around with the password files. I'm not sure if /etc/passwd or /etc/shadow is used on the GP2X.
 
Orkie posted on Mar 3 2007 at 08:49 AM said:
I'm not sure if /etc/passwd or /etc/shadow is used on the GP2X.
/etc/passwd is.

Now that I am sober (not that I've had breakfast yet), he could try this:

Code:
#! /bin/sh
cat /etc/passwd > /mnt/sd/passwd.txt
cat /etc/shadow > /mnt/sd/shadow.txt
sync
exec /usr/gp2x/gp2xmenu

That would at least let us see what he has. If the root password entry is (which it will be):

Code:
root:<something>:0:0:root:/root:/bin/sh

Then the script should work. If sed on busybox for fw3 does things differently then shouldn't the script fail on `test`?

Still there could be a risk.


Code:
#! /bin/sh
cd /etc
cp passwd passwd_dave
sed '/^root/d' passwd > passwd_fix
if [ -f passwd_fix ]; then
		echo "root::0:0:root:/root:/bin/sh" > passwd
		cat passwd_fix >> passwd
fi
sync
exec /usr/gp2x/gp2xmenu

edit = sync (damn you GPH)...
 
Last edited by a moderator:
The easiest way of fixing it is to just reflash 2.0 and don't set a password next time - you don't need it anyway.
 
Back
Top