Sunday, September 6, 2009

How to change your iPhone SSH password after you've lost the password

This guide is for people who have changed the default root password from alpine to something else. And unfortunately, have forgotten to write down the password and now they can't ssh anymore into the device.

I thought I would make this contribution to the web because all the past guides seem to refer to this app called iCommander, which doesn't seem to be available on iPhone firmware 3.0. So without further ado:

What you'll need it is a Windows machine. You will want to google an application called iPhoneBrowser. It lets you transfer files from your iphone without ssh through the USB cable. On a mac, maybe a similar application is available that is able to accomplish the same thing. You will need iTunes installed, or the iPhoneBrowser will not start correctly.

on iPhoneBrowser, connect your iPhone, go to /private/etc directory

download the file master.password to your desktop. Open this file with notepad. be careful not to touch anything in here that is not necessary.

You will find a string that looks similar to this:

root:/myoldpasswordhash:1:2::3:4:System Administrator:/var/root:/bin/sh

replace the line with

root:/smx7MYTQIi2M:0:0::0:0:System Administrator:/var/root:/bin/sh

Save the file, and overwrite it on your iPhone with iPhoneBrowser. Now you can ssh in your iphone again with the password of alpine, and the username of root.

One last tip, change your password again using a ssh client like putty.exe by logging in and running the passwd command. This time, write this new password down. :)