Short and Sweet SSH Guide for the iPhone

Illustration for article titled Short and Sweet SSH Guide for the iPhone

Click to viewAlthough using iBrickr or iFuntastic to get files and applications on and off your iPhone is fine, it's sort of a pain to have to dock it every single time you've got a new NES ROM you want to play. There's an easier way thanks to SSH, the remote command line tool that Linux and Unix users have been using since 1934. With this, you can browse and copy files to and from your phone with either a command line or even a FTP client that supports SFTP. Here's what you do.

Advertisement

Connecting to the command line:

The first step is to jailbreak your phone. Jesus's guide will get you started with both AppTapp for Mac and iBrickr for Windows. They're both just as good. If you're on Windows and using iBrickr, you have to go to the extra step of installing Installer.app onto your phone. You can do this inside the Applications section of iBrickr.

Advertisement

Now, open up Installer on your iPhone and install the "BSD Subsystem", "Community Sources", and "OpenSSH". OpenSSH installs the program that lets you connect onto the iPhone remotely, and BSD Subsystem gets you some command line tools on the phone itself to do some file manipulation. Once done, turn your phone off and on (just to be safe) and you should be ready to connect.

Next, connect to your home's Wi-Fi network and find out what your iPhone's IP Address is. It should be listed under the clients section of your router's configuration pages. An even easier way is to look in your Settings App, under the Wi-Fi network you're currently connected to. [Thanks Ravi!]

If you're on a Mac, you already have a built-in SSH client. If you're in Windows, you can use Putty. Now, open up Terminal (Mac) or Putty (Windows) and connect to your iPhone.

Illustration for article titled Short and Sweet SSH Guide for the iPhone
Advertisement



On Mac, just type in "ssh root@IPADDRESS" without the quotes. Accept any authentication requests that pop up. Type in "dottie" as the password when prompted.

On Windows, enter in the IP Address into the "Host Name (or IP Address)" in putty and hit Open. Accept any authentication dialogues that pop up. Log in as "root" when prompted, with the password "dottie".

Advertisement

Once you're in, you can move around freely with these command line basics.

If you have programs like Erica's Tools installed, you can even take screenshots and copy them onto your desktop.

Advertisement

Copying Files:

Although you can easily copy files from the command line, the easiest way is to do it graphically with an SFTP client. On Mac, you can use Transmit. On the PC, there's WinSCP. The basics are the same, Just enter in your IP address, the login (root), and password (dottie). Now you can drag and drop files to and from your phone easily.

Changing your password:

If you enable SSH on your phone, you should change the password from "dottie" as soon as possible, otherwise people can easily get into your phone and find out what horrible, horrible taste in music you have.

Advertisement

Just log in to your iPhone, then type "passwd". You'll be prompted to enter in the new password. Thanks Premek, I didn't know it was installed!

Deprecated instructions below:

On Mac, type in:

perl -e 'print crypt("MYPASSWORD", "XU");'

Where "XU" is a random two letter combination to randomize your password a little more.

Advertisement

On Windows, you'll have to download and install perl before you run that command. (This is a stupid way to do it. Does anyone know of an online generator or an easier way for Windows?)

Illustration for article titled Short and Sweet SSH Guide for the iPhone
Advertisement

Once you have your new encrypted password from the output of that command, copy the file /etc/master.passwd from your iPhone onto your computer, and replace the root password in the file. The relevant line looks like this:

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

Replace only the X's with your new encrypted password, making sure not to mess up the colons, and upload this back into your phone under /etc/master.passwd Now, reboot the phone. Your new password should be in place.

Advertisement

That's it! If you have any questions or see any holes, make a comment.

Share This Story

Get our newsletter

DISCUSSION

@xdcdx:

Well, I don't know how scientific this is, but I ssh'd in to the iPhone that's been up and running for a while (of course with OpenSSH installed) and did a Top. Here's what I got:

Processes: 22 total, 1 running, 21 sleeping... 83 threads 16:31:47

Load Avg: 0.35, 0.11, 0.04 CPU usage: 9.9% user, 11.7% sys, 78.4% idle

SharedLibs: num = 0, resident = 0B code, 0B data, 0B LinkEdit

MemRegions: num = 2661, resident = 47.1M + 0B private, 20.8M shared

PhysMem: 18.3M wired, 20.4M active, 10.5M inactive, 49.2M used, 2.03M free

VM: 298P + 0B 10412(0) pageins, 0(0) pageouts

PID COMMAND %CPU TIME #TH #PRTS #MREGS RPRVT RSHRD RSIZE VSIZE

19516 top 9.9% 0:08.69 1 17 47 832K 472K 0B 4.45P

18928 sh 0.0% 0:01.19 1 13 30 304K 960K 0B 4.22P

18897 sshd 0.0% 0:02.00 1 14 30 328K 608K 0B 2.89P

14560 MobileSlid 0.0% 0:41.77 2 77 188 2.14M 4.71M 781T 10P

13476 MobileMusi 0.0% 0:01.95 2 49 166 2.02M 4.73M 234T 11P

7667 MobileSafa 0.0% 2:01.46 6 181 442 18.6M 12.7M 2.37P 141P

48 MobilePhon 0.0% 0:04.31 2 103 210 2.83M 6.43M 0B 21P

27 notifyd 0.0% 0:10.18 2 152 25 212K 252K 0B 1.58P

26 PXLdaemon 0.0% 0:02.11 1 15 103 584K 1.19M 0B 3.31P

25 mediaserve 0.0% 0:08.83 14 150 166 1.41M 1.61M 78.1T 7.44P

24 ptpd 0.0% 0:01.39 2 51 71 512K 1.04M 0B 3.97P

22 syslogd 1.8% 12:55.79 3 35 28 216K 272K 0B 1.67P

21 lockdownd 0.0% 0:02.47 3 46 74 596K 884K 1.18P 4.67P

20 mDNSRespon 0.0% 0:03.13 2 45 48 424K 580K 0B 3.27P

19 iapd 0.0% 0:05.29 4 80 144 900K 2.09M 0B 5.89P

18 cron 0.0% 0:01.15 1 13 42 276K 364K 0B 1.84P

17 crashrepor 0.0% 0:01.06 1 41 60 364K 456K 39.1T 2.20P

16 configd 0.0% 0:35.50 4 129 68 700K 852K 0B 5.39P

15 SpringBoar 0.0% 2:16.05 13 211 545 12.3M 13.5M 390T 47P

13 CommCenter 0.0% 0:09.51 10 87 76 928K 700K 0B 5.59P

12 BTServer 0.0% 0:01.48 5 53 70 588K 1.09M 0B 5.19P

1 launchd 0.9% 9:08.00 3 65 28 232K 296K 0B 1.67P

So, even while OpenSSH is being actively used (i.e., me logging in, running Top, etc.), it's consuming very little CPU cycles.