How To: Connect to Your iPhone Via SSH

Cyberduck screencap

We never seem to get round to doing enough of these How-To sort of posts, but I’m trying to knock out a few on topics that seem to come up frequently on iPhone forums and discussions – such as …

How To Connect to Your iPhone Via SSH

Topic Description: SSH (secure shell) is a network protocol that allows data to be exchanged over a secure channel, in this case between a computer and your iPhone.  If you have a jailbroken iPhone, an SSH connection over a wireless network is often the best way to browse your iPhone, carry out simple file transfer back and forth to the iPhone, or manually install applications to it.  This short guide provides a rundown of how to establish an SSH connection to your iPhone.

Requirements & Assumptions:

A jailbroken iPhone.  For this guide we will assume you are running the current latest iPhone firmware, Version 1.1.4.

An SSH program on your computer.  A couple of good free options are WinSCP for a Windows PC, and Cyberduck for a Mac.

The BSD Subsystem installed on your iPhone.  You’ll find this under the System category in Installer.

OpenSSH (or another SSH variant) installed on your iPhone.  This is also found under the System Category in Installer.

iPhone and computer need to be on the same (usually wireless) network.  For the sake of this guide, we’ll assume both are on a home wireless network.

An ability to turn SSH On and Off on the iPhone.  SSH programs on the iPhone do not create an icon on the home screen, so one of the easiest ways to do this is to use the BossPrefs application on the iPhone (to install it you’ll need to add the BigBoss source to Installer – which is http://sleepers.net/iphonerepo).  There are other iPhone applications that do this as well, but BossPrefs is currenty the best of these in my view.

Steps:

  • Make a note of your iPhone’s IP address.  To find this, on your iPhone go to Settings > WiFi and tap on the blue arrow to the right of the name of your home network.  On the screen that comes up, note the set of numbers listed in the IP Address field.
  • Turn SSH On, on the iPhone.  With BossPrefs and other similar applications, this is just a matter of tapping on the SSH entry to toggle it on and off.  Please Note:  it is good idea to make sure you toggle SSH back off when you are through using it.
  • Launch your SSH app on your computer.  WinSCP will land you on a new ‘Session’ screen straight away.  On Cyberduck, you’ll need to choose ‘Open New Connection’.  See screencaps at the top of this post and below for a look at how these screens appear. Then you need to fill in a few fields to specify how you want to connect and what device you want to connect to.  The fields are named slightly differently depending on which program you use, but they are similar enough that you should be able to fill them in as follows:
    Hostname or Server = enter your iPhone’s IP address in this field
    File Protocol = should be SCP on WinSCP and SFTP on Cyberduck
    Username = enter ‘root’ (without the quotes) in this field
    Password = enter ‘alpine’ in this field (without the quotes) or whatever you have changed root’s password to, if you have ever changed it.
  • Once you have entered the information as above, hit ‘Login’ on WinSCP or ‘Connect’ on Cyberduck.  It may take up to 30 seconds or so to connect.
  • You will see a confirmation message asking if you will accept key exchange / connection with the device with the iPhone’s address.  You’ll need to say Yes or Allow on these.

Once connected, you are presented with an Explorer-like view of the file system on the iPhone, or of the iPhone and your own computer.  Once there, you can copy files and folders back and forth between the computer and iPhone.

WinSCP screencap

UPDATE: There is shiny, new updated version of this post HERE – with some changes to reflect the current jailbreak environment, the Cydia app store, and newer jailbreak apps that are helpful in this process.

Tags: , , , , ,

Continue reading:

TAGS:




  • mvs2002

    excellent

  • spikeymikey

    I’ve been trying to figure how to SSH for ages – this tip and trick made it so simple to do! A very good and clear “how to”. Many thanks.

  • http://isource.com/ patrick

    mvs2002 and spikeymikey – thanks for the feedback – so glad to hear this as helpful to you!

  • fleurya

    Thanks for the walk-through. I’m trying to connect to my iPhone, but it looks like OpenSSH is no longer available on installerapp. I went through all packages and it wasn’t there. Is there another SSH in installerapp I can use?

    • mrbobmicjoe

      change ur settings
      go to manage tab in cydia and click settings tab and change ur level to hacker or developer

  • http://isource.com/ patrick

    fleurya – sounds like you need to update or install Community Sources (under the Sources category) – OpenSSH is definitely still available. I just put it back on last night after latest jailbreak efforts …

  • http://alexnichols.com alexnichols

    How do I enable community sources?

  • http://isource.com/ patrick

    Community Sources should be there by default in Installer. You may need to update them to see everything properly – look under the Sources category – if Sources is listed there, install it. If it listed under Updates, update it.

  • Pingback: Why and How I Jailbroke my iPhone « onlydarksets()

  • Pingback: Have you jailbroken your iPhone? - Page 3 - PDAPhoneHome.com()

  • Pingback: tramadol()

  • Pingback: iPhone Tip: Things To Check If You Cannot Connect Via SSH | Just Another iPhone Blog()

  • McDougal

    once they are transferred to your phone, where can i pick up my things I transferred in my phone?

    • http://intensedebate.com/people/patrickj patrickj

      McDougal – depends what you transferred. If it's themes, you'll need to use Winterboard or similar. If it's word processing documents or similar, you'll need an app that lets you view and / or edit those.

  • http://www.artistsvalley.com josh

    hey, my wireless is buggin out for a while… I think its my router… so I cannot SSH into my iphone through the wireless IP. Is there any other way to do this? iPhoneBrowser works… but I cannot set folder permissions in that which is what I want to do so bad! My photo folder permissions are messed up so now I cannot store photos thats clicked. :(

  • http://intensedebate.com/people/patrickj patrickj

    josh – sorry to hear you're having WiFi troubles. I haven't really been running jailbroken in quite a while. Is the MobileFinder app still around? If so, I think I recall that you could change permissions through there if needed. If not, I can't think of another good suggestion, other than to ask your question in EIC or MMi or Macrumors iPhone forums. Hope it works out for you.

  • 4znpr1de98

    I don't get it. Nothing works for my username and password and when I resetted the password thinking that would help, it didn't.

    • http://intensedebate.com/people/patrickj patrickj

      I think you can get some unexpected results when changing that password, so may be best to change it back – at least for the purposes of getting SSH going (and change it again afterwards if you like). Tell us more about what errors you get and perhaps someone here can help.

  • you

    how can i know the iPhone IP?

    • http://intensedebate.com/people/patrickj patrickj

      Go to Settings > WiFi and look for the network you are currently connected to (with a little check mark on it) – click on the blue arrow at the right of the network's listing. That should take you to a screen full of information, including the IP address.

  • john

    after ssh into iphone how do i knows where to put what. for example if i have a book or documents which folder do i put it in

    • http://intensedebate.com/people/patrickj patrickj

      John – that depends on which apps you use to work with those books / documents. If you have any jailbreak apps that can access specific areas of the file system and use them as their default storage areas, you'll need to place your content wherever the app instructs you to put it. This will be app-specific – and of course will only be available via jailbreak apps.

  • Divegirl

    I have a regular Iphone (not jailbreak) and just went into the need to do a restore. I haven't backed up in the last month or so and have some new pics/numbers on the phone that I want to capture before I restore. Any suggestions or am I out of luck?

    • http://intensedebate.com/people/patrickj patrickj

      If I am understanding you correctly, the iPhone is now at a stage where it is forcing you to do a restore. As in, you cannot boot it up normally. If you are sure of that and if you've tried hard reboots and cannot get any farther, then I don't know of any ways (barring forensic-level recovery tools) to get that data backed up.

      If you can still boot the phone, you have lots of options of course.

  • http://www.facebook.com/profile.php?id=1421173967 Justin Mccaffrey

    hey i got openssh i got cyberduck i entered my ip address but im having a few problems maybe im not doing this correctly i first tryed entering my ip as follows 000.000.0.000 and like that with the periods it disconnects me immediately when i enter it without the period in the bottom left corner of cyberduck it says resolving then mounting but it then says it failed and in red lettering it says operation timed out ive tryed this many time and it just keeps doin the same thing do you have any suggestions? or advice am i doint anything wrong

    • http://intensedebate.com/people/patrickj patrickj

      Hey Justin – the problem is that is not a valid IP address. If it's a home WiFi network, most likely your address should start with 192.168.x.x.

      To find your iPhone's IP address, go to Settings > WiFi and in the 'Choose a Network' section look at the network name with a checkmark next to it. Click the little blue arrow at the right of the bar for that network. On the next screen you should see a list of items, one is the IP address entry. Let us know what that address is, or the beginning of it at any rate.

      • http://www.facebook.com/profile.php?id=1421173967 Justin Mccaffrey

        my ip does start with 192.168. i was just using the zeros as an example because when i do it 192.168.x.xxx it says disconnected right away but when i enter it 192168xxxx it says mounting and the load circle is spinning but it doesnt connect and it just says operation timed out i am on a mac and im using cyberduck i changed it to sftp but its not working on the cyberduck window it also says 21 so im not sure if im doing something wrong

  • http://www.facebook.com/profile.php?id=1421173967 Justin Mccaffrey

    actually scratch that i figured that out and im connected now but what folders do i go to in order to copy the videos that i record on cycorder i found the cycorder folder and what do i do when i find the folder thanks

    • http://intensedebate.com/people/patrickj patrickj

      Cyberduck should give you an Finder-like view, showing the folders / files on your iPhone, as well as those on your Mac.

      You should be able to just drag and drop your video files over from iPhone to Mac.

  • Pingback: Our Top 15 iPhone Jailbreak Apps | Just Another iPhone Blog()

  • Shelly

    The root user or the alpine password is not working… It keeps saying that the login name is wrong and I have tried it many times. Is there a way to get your own user name and password?

  • http://intensedebate.com/people/jw1 jw1

    If anyone is having problems connecting their iphone to Cyberduck, after the update. Cydia has left out BSD Subsystems. so there is no download available.

    OK Here is what you do!!! Download Mobile Terminal from ROCK installer.
    Open the app.
    Then type passwd.
    It will say old password. Type in the password you want!
    Not the old one alpine.
    Then type it in again.
    Bam! your done! Open up cyberduck log on as root and your password and
    Bam! your there.

    • gfx

      I did what you suggested and still things did not work. Still getting an error with Cyberduck

      • http://intensedebate.com/people/patrickj patrickj

        If you give some details on what error you're seeing, then somebody may have a suggestion on how to resolve.

  • gfx

    Sorry 'bout that. Here's the error I'm getting:

    I/O Error: Connection failed

    sftp://10.0.1.4

    There was a problem while connecting to 10.0.1.4:22.

    My wife's iphone works like a charm but mine does not.

    • http://intensedebate.com/people/patrickj patrickj

      You have OpenSSH installed on your iPhone and turned on via SBSettings or similar?

    • Daniel

      I was having this same problem, ended up scouring a bunch of articles and doing a bunch of unnecessary things that didn't help… the solution for me was quite simple – maybe it will work for you!

      After you've installed OpenSSH on the iPhone via Cydia, restart your phone.

      Then, turn off the Auto Lock under Settings by selecting "Never".

      Turn on your WiFi connection… then, if you have SBSettings, you can use it to verify that OpenSSH is on (but it should be automatically in the background anyway)…

      Next, open Cyberduck on your computer – select Open Connection…

      Here's the critical step that made it start working for me — SELECT "SFTP (SSH File Transfer Protocol)" from the dropdown menu (it was defaulted to an FTP connection)!

      Then enter "root" as username, "alpine" as password (unless you changed it manually through Mobile Terminal as per jw1's suggestion, which I did not…)

      And it should work! At least it did for me — the problem was I overlooked the default selection for an FTP connection in the dropdown.

      Hope this helps! :)

  • Ash88

    i was able to ssh into my itouch using winscp without toggleing the ssh button on sbsettings! any idea why?

    • http://intensedebate.com/people/patrickj patrickj

      Likely because it is on by default – and you will want to use SBSettings to turn it off except when you need to use it, for both battery life and security reasons.

  • http://intensedebate.com/people/sayhear sayhear

    what if i don't have wireless?

  • garrett

    I finally got this to work…..
    Got all my videos off my phone with sftp
    Use your IP address
    Settings>Wifi>Click on connection to see IP address
    Or it is now listed in the top part of the App itself
    Use this IP addy as host…
    BossPrefs – Turn SSH on…
    It would not work for me defining port 8080…I left it blank!
    Couldn't get it with Cyberduck or Filezilla….
    Had to use old faithful: Rbrowser…purchased version….
    I use this all the time so it is worth it! FTP and SFTP
    user: root
    pass: alpine
    files are located at: /private/var/mobile/Applications/5BCBAF3E-2FB8-482B-86BC-0F795AC9370C/Documents

  • creamyrimmers

    read all the info which is good so far but the bossprefs won't open up after being installed on my 3gs running 4.0.1. Any help please???

    • Asterix

      Same problem with bossprefs. 3gs and 4.0.1

  • Kenny

    Hi, I don't have a wifi, I connect my internet tru cable, it's a broadband. how do I SSH with the broadband internet? thanks.

  • darryl Saldanha

    Thanks a Lot,
    worked .. =D

  • Pingback: Vista = Perfection? On The iPhone? « Just Another iPhone Blog()

  • MrVinny08

    I downloaded bossprefs and when it attempts to open it closes i tried reinstalling it but it doesnt let me, can anyone help me?

  • sal

    i have tried everything written above but it gives me
    I/O Error: connection failed
    connect time out

  • wulfy

    im totaly disabled from my itouch (ran out of chances to try to type in password)
    and da only computer i synced with is on da other side of earth (im in taiwan n my computer is in canada)
    and i have my ssh turned off, and i can’t get to it through the “more” btn on sbsettings…..
    is there another way to turn it on? D:

  • Alex

    all done, just that when i’m trying to copy an .ipa file for 1gb for example, transfer is sooooooooooooo slow like 20.000 bytes/sec !! its killing me, does anybody know why?

  • Pingback: Mobile Terminal keeps crashing! Help!!()

  • Kapil Saini

    I am facing the error , “connection refused”
    Do i need to connect my laptop and iphone through cable also.