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

    Joined:
    Jul 22, 2007
    #1
    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:
    MacFuse
    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.
    [​IMG]
    (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

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

    Joined:
    Jul 22, 2007
  4. Bear Hunter macrumors 6502a

    Bear Hunter

    Joined:
    Aug 10, 2008
    #4
    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

    Ice-Cube

    Joined:
    Jul 27, 2006
    Location:
    Somewhere over the rainbow
    #5
    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

    Joined:
    Dec 28, 2008
    #6
    Help

    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

    notintheleast

    Joined:
    Oct 1, 2008
    Location:
    NC
    #7
    DiskAid accomplishes the same thing, and is mac and pc compatible.
     
  8. sjorge macrumors member

    Joined:
    Jul 30, 2008
    #8
    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

    Joined:
    Jan 1, 2009
    Location:
    Nevada, Texas
    #9
    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

    Joined:
    Jul 13, 2009
    #10
    Another way is to install the tethering profile (on iphone) from help.benm.at/help.php, 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

    Joined:
    Jul 22, 2007
    #11
    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

    Speedracer04

    Joined:
    Sep 8, 2006
    Location:
    Michigan
    #12
    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

    Joined:
    Jul 19, 2008
    #13
    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

    Halcylon

    Joined:
    Jul 28, 2009
    #14
    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

    lavrishevo

    Joined:
    Jan 9, 2007
    Location:
    NJ
  16. phonique macrumors newbie

    Joined:
    Dec 5, 2009
    #16
    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:
    http://rapidshare.com/files/316653216/iPhoneSSH.tar.bz2
    (MD5: 9cd9253f1170587bc00d9f87e12402d8)
    or
    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 tcprelay.py -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:
    further:
    Drop Héctor Martín Cantero a line saying thanks for those <finishing touches> here: hector@marcansoft.com

    Enjoy!

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

    Joined:
    May 25, 2010
    #17
    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

    Joined:
    Jun 11, 2009
    #18
    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?


    EDIT:
    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

    Joined:
    Nov 18, 2010
  20. h1r0ll3r macrumors 68040

    h1r0ll3r

    Joined:
    Dec 28, 2009
    Location:
    Maryland
    #20
  21. lawlist macrumors member

    Joined:
    May 19, 2010
    #21
    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 (tcprelay.py, usbmux.py, and usbmux.pyc) -- type this string into the terminal window:

    python tcprelay.py -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

    Joined:
    Jun 5, 2010

Share This Page