How-To: SSH to iPhone Over USB (OSX Only)

Discussion in 'Jailbreaks and iOS Hacks' started by Knolly, Sep 19, 2008.

  1. Knolly macrumors 6502a

    Jul 22, 2007
    EDIT: DiskAid is far far easier. Ignore the rest of this tutorial.

    Disclaimer: Technically you're not SSHing... You're just making a USB connection that accomplishes the same thing.

    So anyhow, I had a need for this setup due to a really complicated WiFi situation that made SSHing a huge ordeal... So here we go!

    1. Download and install:
    Disk for iPhone
    Then restart your computer.

    2. Plug in your iPhone.

    3. Open Disk for iPhone. Media will show up on your desktop.

    4. Click on the Disk for iPhone icon in the status bar and select root.
    (Yeah, I know, pic taken from their site because I'm too lazy to go make screenshots and this is pretty dead simple)

    5. Root will show up. Now the slightly tricky bit is that Aliases within the root directory do NOT work. So, go to the following: private/var/stash. Or, with root mounted, open Finder, click Go on the status bar and select Go to Folder and copy and paste "/Volumes/Root/private/var/stash."

    The stash folder is where you'll find Applications and Themes, among other things. While there are other things you can do with SSH those two are by far the biggest ones.

    And there you go, that's all there is to it. Quick protip so you don't have to bother with folders though: If you make an alias to the stash folder and put it on your Mac somewhere, all you have to do is connect the iPhone, start Disk for iPhone, select root, and double click on the alias to get where you need to go.
  2. djdizzy macrumors member

    Jul 15, 2008
  3. Knolly thread starter macrumors 6502a

    Jul 22, 2007
  4. Bear Hunter macrumors 6502a

    Bear Hunter

    Aug 10, 2008
    Why don't you just create an ad-hoc network between your computer and phone and SSH that way? That way your not relying on an external Wifi source.
  5. Ice-Cube macrumors 6502a


    Jul 27, 2006
    Somewhere over the rainbow
    I just experienced a crash when I attempted this. Don't know what happened, but I def won't try it again.
  6. cava857 macrumors newbie

    Dec 28, 2008

    hey me too, i was trying to do the mobile installation thing, and it crashed, i have to restore it :mad:
  7. notintheleast macrumors 6502


    Oct 1, 2008
    DiskAid accomplishes the same thing, and is mac and pc compatible.
  8. sjorge macrumors member

    Jul 30, 2008
    bah here I was hoping to have a bash shell on the iphone without having wifi running. a lot of people seem to confuse ssh with scp (sftp) which uses the ssh protocol for file copy. :(
  9. DirtyDan macrumors member

    Jan 1, 2009
    Nevada, Texas
    I messed with both, DiskAid was much easier, faster, seems more stable/secure, and it doesn't require a restart.

    However, MacFuse is free and DiskAid is only a 14 day demo.

    I'd rather pay for the easy stuff. :D
  10. fullprooffed macrumors newbie

    Jul 13, 2009
    Another way is to install the tethering profile (on iphone) from, then set up tethering via usb by following the provided directions, then download Transmit from the apple site and set up the ssh file transfer like you would do in Cyberduck or any other ssh client. The tethering connection uses the usb cable versus using a wifi connection.
  11. Knolly thread starter macrumors 6502a

    Jul 22, 2007
    Massive agreement that DiskAid is easier... It either wasn't out or for some reason I didn't know about it when I wrote this.
  12. Speedracer04 macrumors 6502a


    Sep 8, 2006
    Does DiskAid actually let you modify permissions on folders and files?

    If not its just a file viewer and not SSH
  13. mohicanspap macrumors regular

    Jul 19, 2008
    How would one manage a ad-hoc network? I already know how to connect the two devices but how to you access the iPhone through Cyberduck? Is it a FTP or a SFTP?
  14. Halcylon macrumors newbie


    Jul 28, 2009
    I still managed to botch this up regardless of the simple instructions. I downloaded Disk for iPhone and restarted, having already had MacFuse and now when I plug in the iPhone and run Disk for iPhone it closes immediately.
  15. lavrishevo macrumors 68000


    Jan 9, 2007
  16. phonique macrumors newbie

    Dec 5, 2009
    The real solution

    Until novi's iphone tunnel works again...
    (Obviously, works only if you have SSH or another server installed on your iPhone/iTouch.)

    1. Download iPhoneSSH.tar.bz2 (~25KB) from here:
    (MD5: 9cd9253f1170587bc00d9f87e12402d8)
    Download the latest usbmuxd distribution from here:
    Abort, Retry, Hack? usbmuxd
    2. Unpack to a convenient location (you just need the "python-client" folder if you downloaded the usbmuxd distribution)
    3. Open terminal, change directory to the python-client-folder and type:
    python -t 22:2222 &
    (the -t is for threaded-mode, meaning that you will be able to open more than one session/forward more than one port (as shown below))
    4. Now open Fugu or another terminal session and connect to localhost @ port 2222 i.e. like this:
    ssh -p 2222 root@localhost

    Enjoy SSH over USB!

    Additional info in the author's words:
    Drop Héctor Martín Cantero a line saying thanks for those <finishing touches> here:


    Tested and confirmed working on 10.6.2 and iPhone 3.0-JB.
  17. mjamz macrumors newbie

    May 25, 2010
    Thanks phonique!
    It worked for me too, just want to stress out for everyone trying this out: don't forget to enable ssh mode on your iPhone and you have to switch your terminal session. (Didn't get it at the first try, phoniques HowTo is not hard but you have to read it twice! But then it is really easy!)
    My iPhones modem broke (as with many other iphones these days..) and I worried if I could continue SSHing into it. It works and it saved "my" iPhone for me: SSH is so much more than a file viewer, it allows you to use your Phone like a computer.
  18. thedoobieman5 macrumors newbie

    Jun 11, 2009
    I just did things phonique's way and I can SSH like it's nobody's business (plus it's way faster). However, I can't seem to copy files back and forth. When I use scp I'm asked for a password that isn't any of the ones I use. Does anyone know what's going on?

    Nevermind, the answer was in the man pages all along. Anyone that's having the same problem should note that "scp -P" is what should be used, not "scp -p". Excuse my n00bishness.
  19. kocx macrumors newbie

    Nov 18, 2010
  20. h1r0ll3r macrumors 68040


    Dec 28, 2009
  21. lawlist macrumors member

    May 19, 2010
    ssh via usb iphone mac osx python terminal cydia openssh

    For those users like myself who are technologically challenged, this post is designed to help them understand that an iphone 4.1 can indeed be connected to the mac via ssh over usb (e.g., even with wifi turned completely OFF, if so desired) (on a mac running osx 10.6.5 snow leopard). During the past couple of months, I must have read this thread a couple of times and left being confused because ssh via terminal is for advanced users. The terminal window that needs to be used to initially set this up is on the mac in the utilities folder (no need to use a terminal window on the iphone), and the user needs to execute the python string in the terminal window from within the folder ON THE MAC containing these files (,, and usbmux.pyc) -- type this string into the terminal window:

    python -t 22:2222 &

    Any sftp client for the mac will work (e.g., cyberduck, forklift, expandrive, etc.) -- the trick is to use the name localhost as the server name, and port 2222. The transfer speed is slightly faster than wifi. I hope this helps a lost soul like myself who thought there was no way to ssh over usb on the mac into an iPhone with semi-current firmware (i.e., 4.1). Of course, this requires openssh installed through cydia to work -- but nothing else extra from cydia is required that I am aware of based upon the current jailbreak that I used from greenpois0n.
  22. APtalent macrumors regular

    Jun 5, 2010

Share This Page