So you forgot the root or mobile password to your jailbroken iphone and can't ssh into it any more. Well it sucks to be you, or at least it really would if you couldn't read this. So follow the instructions below to set a new password.
A note: apparently the 'passwd' utility just screws everything up, so never use that in-case that's still true.
Just so you know what we're doing, our objective is to get root write control to the file system so you can change the password in /etc/master.passwd . This should be simple as all apps run as root (or so I hurd). We do this by installing iFile, copying
Note that everything is (obviously) 'minus quotes'. That means if I say type "echo hello" don't type those double quotes.
Well here's the instructions:
1. Open up cydia
2. Wait for it to do that "Loading data" crap and hope that it's loading something more than 'home' because you're just going to go straight to search.
3. Search for a package called iFile.
4. Install iFile.
5. Once iFile is installed close cydia and open up iFile.
iFile is a program that will let you browse, open, and maipulate files. This includes moving them. It dose this with root powers.
6. In iFile browse to the /etc directory (top left a few times, then find 'etc' and tap that).
7. Once in /etc/ scroll down to a file called 'master.passwd'.
8. Press the edit button (top right).
9. Tap on the letters 'master.passwd' that indicate the file 'master.passwd'. This should put a little red dot to the left of it.
10. Tap the icon/button thing in the bottom right (looks like an arrorw speeding out of a picure frame (or one of those pictures you get after roller coasters, upside down).
11. Select 'copy'.
12. Tap 'Done' (top left, where edit was).
13. Tap the home icon/button thing (bottom, second from the right, looks like a house).
Now you're in '/var/mobile' if I am correct.
14. Tap edit again
15. Tap that bottom right copy/cut/paste arrow-in-a-picture-frame button thing that you tapped before (I'd tap that).
16. Tap paste.
17. Tap the blue circle to the right of 'master.passwd'.
18. See where is says 'Ownership', followed by these two lines:
Owner root >
Group wheel >
tab on owner, change it to Mobile. Then do the same for Group. So you have:
Owner mobile >
Group mobile >
19. Close iFile.
20. Go to terminal (I presume you already have it installed as you use openSSH, is that a good presumption? Dose everyone have Terminal? Well if you don't: install Terminal just how you did with iFile (through cydia)).
19. In the terminal (type pwd and make sure you're in /var/mobile, if it dosen't say '/var/mobile', type "cd /var/mobile" )
21. At the terminal type: "grep ^root master.passwd" you should see something like:
22. Take note of the string or random-looking letters and numbers between the first two colons (in the case above 'UlGq3RrXWDrOc') that is the password 'hash', an encrypted form of you password that cannot be unencrypted.
23. Next you want to generate a new password hash. You can do this with the perl function 'crypt'. If you've no idea what that is head over to Test crypt online
. At that website you see a large text area with $str above it, and a one-line text input with $salt above it. $salt can be any two characters, I chose Ul as that was what was there before and that makes me feel safe for some reason. In $str will be where you type your new password, go ahead and do that, and salt. Next click run.
24. You will get a result like what you previous hash was (note if you've done this a different way and get something that looks like: $1$Rt79jmd6$526Di9l3ra//YfQ7BvD./1 that's bad, that's why you're going wrong. It should be shorter and without dollar signs).
25. First backup the master.passwd you have in case do make a boo boo and have to start over. Do this by typing "cp master.passwd master.passwd.bak".
26. Now you're going to edit the copy of master.passwd you have to replace the old hash with the new hash using a line similar to this: "sed -i s/root:OLD_HASH/root:NEW_HASH/g" replacing 'OLD_HASH' AND 'NEW_HASH' with you old hash and your new hash. For example:
My old password was 'miakirshnerishot' and I want to change it to 'miakirshnerisREALLYhot!1!'.
Password , , , , , hash:
Then at the terminal I'd be typing (stuff I type has a '$' before it:
$grep ^root master.passwd
$sed -i s/root:UlD3amElwHEpc/root:UlRsc4Sqd.Ayg/g
(please not that it's really easy to mistype something and screw it up, triple check both hashes you type in before you press enter.
26. If you want you same for mobile (the user), in which case you'll be replacing 'root' with 'mobile', in the above example there are 3 'root's that you need to replace.
27. Now that you've edited master.passwd you must replace the old one with the edited version. So close Terminal and go into iFile, make sure you're in you home directory.
28. In iFile tap edit.
29. Tap the letters 'master.passwd' to make that red dot appear.
30. Tap the arrow-picture-frame bottom/icon copy/cut/paste thing.
31. Tap Copy.
32. Tap Done.
33. Navigate yourself to /etc
34. Tap edit again.
35. Tap the copy/cut/paste arrow-picture-frame thing again.
36. Tap paste.
37. Choose to overwrite (don't worry you made that backup remember).
38. Tap the blue dot to the left of to master.passwd.
39. Under 'Ownership' change the Owner back to root, and the Group back to wheel.
40. Go back into Terminal and check your root password by typing "su -" and entering your root password. Test the mobile password with ssh if you changed it.
41. Now you can delete the master.passwd and master.passwd.bak in your home directory. Do this by typing "rm ~/master.passwd*".
Congratulations you successfully rooted your iphone and changed the password (wasn't exactly hard was it).