Advertisement

ssh on iPhone

Over at the #iphone channel at irc.osx86.hu, the thoroughly awesome NerveGas has figured out how to enable ssh on the iPhone without using restore mode. The secret lies in overwriting an existing binary and plist to trick the iPhone into calling chmod on the Dropbear ssh server and making it executable.

At this time, NerveGas has used Nightwatch's compiler to create iPhone-compatible versions of curl and ps as well as a number of other useful Unix utilities. (He's working on grep, as I write).

So what does this mean? Well, once you've got ssh installed on your iPhone and active, you can access your iPhone from a shell on your Mac. You can send and retrieve files using scp or sftp. And you can use the compilation toolchain to build other Unix utils or even your own software. It's just a short matter of time until perl and other command-line utilities are iPhone-ready.

Quick Reference

How To. You'll find NerveGas's excellent how-to here.

Necessary files. ssh kit and binaries (with many of the Unix utilities compiled for you).

NightWatch's Binary kit. Download here.

Other utilities. You can download curl, chmod, ps, ifconfig, grep, ed, vim, netcat. You can also find a compilation binkit here.

How do I ssh from my Mac? Look up the IP address under your WiFi settings (click the blue right arrow next to the WiFi network you choose). Then from the Mac's terminal, enter ssh root@IP address and use dottie as your password.

How do I get these to execute. Use /bin/chmod until you can get a shell going. For example, /bin/chmod 555 /bin/ls.

How do I enable scp and sftp? Use NiteWatch's binary kit. Make sure to install all the items in the /usr/tree including the /usr/lib files, otherwise you'll get an error when attempting to run the sftp-server.

How do I get a path to work? Run a shell, like csh, and use the path commands in the shell. I've set up a .cshrc to make things easier.

Where do I get the source for iPhoneInterface with getfile/putfile? The public svn, where you can pull the source, is here. You can grab the latest update to the main.cpp file here.

Thanks to NerveGas and also to pen-x for figuring out how to get Dropbear working and Nightwatch who got the entire compilation toolchain working, to iZsh, bricolage, and to BabyJesus.