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.











Reader Comments (Page 1 of 2)
7-23-2007 @ 3:26PM
Clark Goble said...
While this is pretty cool, how many want to be it gets plugged in the next major iPhone update?
Reply
7-23-2007 @ 3:29PM
Erica Sadun said...
Michael: That's what I 'm doing now. I'm on the Mac and accessing the iPhone over WiFi. Cool, huh?
Reply
7-23-2007 @ 4:10PM
Robert said...
Erick: They provide steps for creating a different password.
Reply
7-23-2007 @ 4:20PM
Michael B. said...
what I want to know: Has anyone remote access TO the iPhone. from Mac to iPhone. Like what happens if you get the iPhones IP and try remote logging in and other things.
What about taking the iPhone software (either through Apple or using DiskUtil's restore and putting it in an emulator the supports the ARM processor. The free Q.app does, but I don't have an iPhone - and can't unlock that dmg.
Just throwing out ideas.
Reply
7-23-2007 @ 4:31PM
Erica Sadun said...
Ftp isn't enabled. And you need to follow the directions to enable sftp.
Reply
7-23-2007 @ 4:37PM
Michael B. said...
oh never mind- Im a bit out of it right now. I wish this were simpler.
Oh yeah what happens (now that you know the password) if you go into Safari or Finder and enter ftp://[ip address] I tried it in the Apple Store but was prompted for a password - I didn't know it. And if you have invisib;e files turned on in Finder what can you see?
Reply
7-23-2007 @ 4:48PM
Andy said...
I don't want to ssh TO my iPhone.. I want to ssh FROM my iPhone. And with a real client, not some web workaround.
Reply
7-23-2007 @ 5:03PM
Aron Trimble said...
So Erica, can you use this to remotely add ringtones to your iPhone?
Reply
7-23-2007 @ 5:13PM
Harbinger said...
Next stop, Apple File Sharing and web hosting from the iPhone.
Apple File Sharing = Wireless Sync
Web Hosting = Local Applications
Reply
7-23-2007 @ 5:56PM
Brandon said...
WHOA... If you can enable RemoteGateway on the ssh server, theoretically you could connect to an ad-hoc wifi connection with your laptop and then ssh to it using a a faux-socks proxy on the laptop client and tether to your EDGE network connection.
I am going to try that now...
Reply
7-23-2007 @ 6:01PM
Emanuele Vulcano said...
Next step: compile a version of otool and nm that is able to read ARM Mach-O exe's, in order to begin understanding how the UI framework works :)
Reply
7-23-2007 @ 6:05PM
Kai Cherry said...
class-dump as well as otool -vT do what you're looking for Emanuele...
Try to keep up ;)
Reply
7-23-2007 @ 7:14PM
ant said...
brillant. purchasing concerns now addressed. next 5 paychecks earmarked.
Reply
7-23-2007 @ 9:39PM
Reg Muffet said...
Another excellent Quick Reference summary from Erica. Saves a lot of time.
But as for thanking *Baby* Jesus, I thought the iPhone was the JesusPhone, so that would make BJ kinda sorta Steve, and Steve's no spring chicken.
http://video.google.com/videoplay?docid=6542481355742550486&hl=en-AU
(Mind you, I never under the trinity thing. Was it the two Steves + Bill Gates from which all creation sprung? I guess Silicon Valley bible classes aren't what they are in Kansas.)
Reply
7-23-2007 @ 10:14PM
Shane Sewell said...
The title of this article should read "sshd on iPhone", since your enabling the SSH daemon (server) on the iPhone, not providing a SSH client.
Reply
7-23-2007 @ 10:37PM
Matt Johnston said...
Dropbear has a client too - you should just be able to compile it up (or they may have already??). Of course first you'd need a terminal app for the iPhone - not sure if they've got that far yet. Good to see some progress though.
Reply
7-24-2007 @ 8:52AM
Robert said...
Any links to an Intel OS X binary of dropbear rather than having to download Apple dev tools and compile?
Reply
7-24-2007 @ 12:17PM
Hubert Lepicki said...
Wow. Now that is just another awesome news about iPhone (sarcasm).
The thing is that it's firmware is not free software, yes it can be built on top of max os X, or other Unix, but do they distribute this modified version? Do they provide useful build system? No. They are not OpenMoko guys :P
I'm not going to buy iPhone, nor advise it to anyone, while OpenMoko will be ready in couple of weeks / months? I'll wait.
Reply
7-24-2007 @ 4:30PM
Robert said...
Hubert: Thank you for your spam.
More importantly, I just saw that the iPhone Dev Wiki posted the following security notice regarding shell access:
Progress Report
Some folks have "raised concerns" (to stay polite) that we were not officially releasing the ssh/shell binaries with instructions. Well, there is a good reason to delay it until we have a proper nice secure packaging for it: unfortunately, it seems a lot of people are currently installing these binaries regardless of basic security measures.
Installing the AFC plist exploit and/or a ssh-shell access on your iPhone is really not a good idea if you don't take the security of your iPhone seriously. It is highly advised that, you:
1. disable the AFC plist exploit (the Services.plist one) when you don't use it
2. change the root's password, disallow root access on the iPhone and create a new account (hint: edit /etc/passwd and /etc/master.passwd).
Because right now, if you don't do this, you're just wide open to any kind of virus/botnet attacks.
Hacking is fun, but stay safe ;)
-- the dev team
Reply
7-24-2007 @ 9:04PM
Nate True said...
Brandon: instructions on tethering your iPhone are here:
http://cre.ations.net/blog/post/tether-your-iphone
Reply