" />

iPhone Tip: Things To Check If You Cannot Connect Via SSH

iPhone WinSCP SSH settings

One of the most common topics that I see come up at iPhone forum sites over and over is problems with connecting to the iPhone via SSH.  So I thought I ‘d do a quick post covering some good things to check when troubleshooting these issues.

These suggestions may not fix every SSH connection problem, but they should help you resolve most, and will certainly mean you ‘ve covered the basics and most likely causes of a connection failure.

In this post I ‘m going to assume that you are already comfortable with the basics of using SSH to connect to your iPhone, and have already got SSH apps setup on both your iPhone and the PC you ‘re using to connect to it.

If you ‘re not comfortable with the above, or need some help with your initial setup, please give my more general How-to post on this subject “ How To: Connect To Your iPhone Via SSH.

Ok, so let ‘s talk about what to do if you ‘ve got yourself all setup “ on the iPhone and PC “ with SSH apps and you still have problems connecting via SSH.

There are a variety of error messages you can get from SSH clients when connections fail.  One of the most common is ‘Network error: Connection refused ‘.  I ‘m not going to try to break this up into sections for every common error message “ for that, you might want to see this post that offers some advice along those lines for common WinSCP errors.

Instead, the suggestions below should be useful things to try for nearly all errors you ‘ll encounter.  Many of them are quite obvious things “ but they are also things that most of us have had at least a few ‘DOH ‘ moments on, and these checks can bring a quick fix when we do.

Things To Try If You Cannot Connect To Your iPhone Via SSH:

  • If you get a timeout error, try increasing the timeout setting
  • Make sure SSH is turned on, on the iPhone – Generally the easiest way to do this is to use an app like SB Settings that gives you a GUI interface to toggle the service on and off with.
  • Make sure WiFi is turned on, on the iPhone “ again, via SB Settings or the iPhone ‘s built-in Settings applet.
  • Check that you are specifying the right port in your desktop SSH app (e.g. WinSCP on Windows or Cyberduck on Mac).  The port needs to be 22.
  • Make sure you are entering the correct “ and *current* “ IP address for the iPhone.  If your iPhone gets a DHCP (dynamically configured) IP address from your router (as most do), then its address can and will change over time.  So its IP address today may be different to the one it had last week when you last successfully connected.  To check this go to Settings > WiFi “ and tap on the blue arrow next to your active WiFi connection “ the screen that takes you to will display the iPhone ‘s current IP address.
  • Verify that the iPhone has a *valid* IP address.  When you are checking the address per the above point, if you see an address that starts with 169.254.x then the iPhone is not getting a usable IP address “ and you need to troubleshoot that issue first.
  • Remember that the iPhone and the PC you ‘re tying to connect from must be on the same WiFi network.  One of the easiest ways to tell this is to see if their IP addresses look similar.  For instance, many default home WiFi networks will have IP addresses that start with 192.168.x.
  • Check that you do not have any antivirus, firewall, or security software on your PC that may be blocking your outbound SSH connection.  One of the easiest ways to quickly rule this out (or pin the blame on it) is to shut down any and all of those services on your PC temporarily and try connecting. If it still fails, you know those services are not to blame.
  • Password check “ you need to be using the correct username and password for connection to the iPhone.  If you have never changed these (which the vast majority of iPhone users have not “ and you would know if you did) then the most likely defaults are username ‘root ‘ and password either ‘alpine ‘ or ‘dottie ‘.  Please note “ you do not type the ‘ ‘ inverted commas around the username or password.
  • The iPhone cannot be in ‘sleep mode ‘ when you are trying to connect.  You may just want to change your Auto-Lock setting to ‘Never ‘ just for while you are connecting “ to avoid this issue.
  • Make sure you are using the correct protocol setting in your desktop SSH app.  This varies according to which client app you are using.  WinSCP uses SCP, for example.

Again, checking and correcting these things may not resolve every connection issue you come across “ but they should help in the majority of cases.  I hope some of you will find these helpful, and look forward to hearing any of your tips you ‘d like to share for these issues.

Continue reading:


  • dkk

    what if you changed your password from alpine or dottie and you dont remember what you changed it to?

  • dkk – have you tried typing 'passwd' (without quotes) in a terminal app and changing the password?

  • Ale

    Hi, I just solved this problem (maybe useful for others):

    I couldn't SSH my iphone -> timeout after a while. Tried everything, reboot phone, mac, reinstall ssh, playing with wireless and ssh, on, off, ……
    in the end I realized that maybe the problem could be my ip configuration:
    router: (recognized also by phone)

    so I tried to give a higher ip to the mac, instead of somehing like It worked!

    Hope can be useful

    • Ale – if I remember rightly, you should never be using .0 or .255 in the last octet (the fourth part) of a private IP adressing scheme, like those we use for our home networks. .0 and .255 are reserved I believe for set purposes – .255 for broadcasts to the entire network and .0 I can't recall what for.

      Anyway, thanks for sharing – and yes, not a good idea to give a workstation an address that ends in .0.

      • Ryan

        .0 is the network mask ID.

  • Kadiblov

    dyld: lazy symbol binding failed: Symbol not found: _login
    on my terminal screen, which then closes…

    Any suggestions ? I am capable of logging through WinSCP File Transfer, but not the terminal…

    • I've not come across this error before. A quick search in Google turned up some forum postings that looked potentially helpful though. I don't know your details with this – think Google is your friend for solutions.

  • Kadiblov

    Thanks Patrickj. This is how I fixed WiFi erratic, Cydia and SSH after Pwnage 3.1.2 on my iPhone 2G. I can´t guarantee is works for everyone, but here were my symptoms after I upgraded to FW 3.1.2 on my iPhone 2G using WinPwn(QuickPwn):

    – Cydia didn´t worked – Opens windows, and closed suddenly. Same thing with Cycorder and Terminal (SSH for iPhone)
    – Icy works, but with late packages – very old versions.
    – Erractic Wifi (sometimes worked for 5 minutes, sometimes for 5 seconds, sometimes doesn´t even shown SSIDs Networks)
    – SSH trials over Wifi (while it was working), using puTTY Terminal provided a error with dyld, on _login package and freezed (dropped connection). Connections using WinSCP however, worked fine, and I was able to browse my iPhone.
    (reason I posted this message originally).

    I searched for several forums, (yes, Google is our friend, despite of its intention to take over the world šŸ™‚ ) to compile what I here propose – and worked fine fine for me:


    1) Open Icy
    2) Go to sources and remove apt.saurik.com as a repository
    3) Close Icy and reboot your iPhone (Power Off cycle, or Reboot using bigboss.us package)
    4) Add apt.saurik.com as a repo again.

    This process refreshed the cache and versions, solving the old package availability. Prior to that, my OpenSSH package was on version 0.4xxx, which caused the dyld _login error, trying to access over puTTY due to lack of library.

    5)Enter on Icy 1.4xxx and find the OpenSSH package on version 0.5xxx (updated). Install and exit Icy.


    After OpenSSH update to 0.5xx, you must connect using Wifi. This was a tricky task, due to Wifi erractic behavior. I´ve tried several recipes, looking for a consistent workaround. What worked the most was 1) Reset Network Settings, 2) Enter Airplane Mode and 3) while in Airplane mode, activate only Wifi. This lead to a status where you have no phone service, which in the end, is good as we´re trying to fix over terminal and don´twant anyone bothering us with a call
    Whenever in Wifi config settings screen, you can see your Wifi networks, reconfigure your SSID Password to your router, and login immediately using puTTY using your iPhone´s IP over SFTP.
    As usual, login as ´root´ and password ´alpine´ standard procedure. It took me more than 5 times to get access, probably due to erractic Wifi behavior, but I finally got access to the terminal prompt.

    Then follow these steps to reinstall cydia and update library
    1) Remove outdated Cydia application by typing: 'apt-get remove cydia' and confirmation phrase.
    2) Refresh entire library by typing ´apt-get update´ and see your library refreshing
    3) Reinstall Cydia by typing ´apt-get install cydia´ It will reinstall and add the apt7 library, which I believe was key to move forward.


    Here were when my Wifi became stable. Cydia identified 36 packages to update !!! Hopefully some of them fixed the Wifi preferences and priorities – I really don´t know exactly what happened, but as you´re stuck as I was, there´s nothing really to lose if you got till here. o/

    Hope it helps !

    • Hey – thanks for sharing and glad you got it worked out. Hate to say it, but I have a feeling another method might have been just to remove Icy and reinstall Cydia. My impression is that Icy is known to cause a number of severe issues.

  • /me have problems… ssh’ing my iPhone 2G is working fine til I respring, then it won’t accept my connection. After respring I have to reinstall/restore openssh in cydia to be able to connect again, sometimes I also lose my sbsetting toggle for ssh after respringing.

    And sometimes winscp will disconnect during session and the same prob occurs.

    Any ideas?

    • Found out whats wrong… I've got the Ikee virus! google for info.

      • Ah, ok – well hope you get restored and back to normal quickly.

  • Al Dunbar

    @Markus, did you have the Ikee virus without seeing the customary Rick Wallpaper? My personal wallpaper disappeared, replaced with the default earth pic, then (or I subsequently noticed) my SSH toggle in SBSettings disappeared. I had trouble connecting via Cyberduck, but managed to get in. After reinstalling some sbsettings and open ssh, I was able to connect. Then my SBsettings toggle mysteriously reappeared. However I am again unable to SSH in using CD (I get a "Premature Connection close." error message. Do these symptoms sound at all like what you had? If so, did you manage to get things fixed?

    • Carlos

      It happened exactly the same to me. Step by step. Now I cannot us ssh. Did you find a solution for this?

  • Sanketh

    What if the Wifi IP Address and Your Computer's IP Address are different what do you do now?

    • You've lost me there. Which WiFi IP address? Generally the only IP address you need to know during this process is he one for your iPhone – which will change periodically if you are using DHCP. When it does, you just make sure to enter the correct / current one in your desktop app you're using for SSH connections

  • Q#1 can you use SSH while connected to a wifi hotspot?
    Q#2 how to change a 169.254 non use able IP?

    • Both the iPhone and the computer you're connecting from need to be on the same local WiFi network. This is do-able at a public WiFi spot but you'll want to make sure you turn SSH back off on your iPhone as soon as you are done transferring files or whatever you're up to.
      You get a 169.254.x.y address when a device is unable to obtain a valid DHCP address. The way to fix that is to connect successfully to a WiFi network with a device that is dishing out dynamically assigned addresses correctly.

  • d8lom

    What if you get an error message saying: "Server unexpectedly closed network connection."

  • Have you tried reinstalling OpenSSH?

    • Jonathan

      hi, "Server unexpectedly closed network connection." I've tried reinstalling OpenSSH and also reinstalled WinSCP, but it still shows. I have no idea how to solve this, anyone can help?

  • KAZ

    i got the same problem as jonathan….i tried reinstalling openssh,openssl,winscp,sbsettings and i still got "Server unexpectedly closed network connection." HELP PLSSSSSS THANKS ALOT!

    • Visar

      hi please if you've solve tha problem can you share it please

  • James

    Turn auto-sleep mode off in your settings. Tell it to never auto-lock the phone or itouch

  • Michael

    how can I make sure that OpenSSH is turned on on my iphone? Witch software I need to use?

  • @Michael – SBSettings is the easiest jailbreak app to use for this. It lets you toggle SSH on and off just like other services.

  • Siva

    “Server unexpectedly closed network connection.”
    Same problem.
    Using Windows Vista Home Premium. Latest WinSCP (4.3.2) and OpenSSH (in Cydia) Ver.5.8p1-9

    Also, autolock is set to Never.

  • @ric

    I am having excessive trouble sshing to my iphone 3g, ios 4.1. I keep seeing an error message connection refused by machine. I assume this is the iphone refusing the connection. I do not have wifi on this device as it was stopped after an apple update several updates ago. Question is, can I ssh into my iphone without the wifi working. sbsettings gave me an ip address This appears to be a private ip address, should work without any probs. Any suggestions would be nice.

  • Roger Delongo

    Thanks for your help! Turns out my ssh was disabled in SSH settings.

  • x

    Probably a bit late to the party, but I finally had a need to jailbreak and decided to use greenpois0n for my iOS4.2.1. It turned out that I also had the ikee virus. (I thought that I was safe because I had never jailbroken before nor had openSSH.) In any case, this article, http://www.iphonefaq.org/archives/97723, pointed to my problem – I didn’t have all of the files, but you pretty much have to check for every one listed to be sure. Since I didn’t know which variant that I had, I ended up removing all of them.

    For known variants A, B or C

    1. Run the Terminal app.
    2. Enter each of the following commands followed by “return” to remove these files.

    rm /bin/poc-bbot
    rm /bin/sshpass
    rm /System/Library/LaunchDaemons/com.ikey.bbot.plist
    rm /var/lock/bbot.lock
    rm /var/log/youcanbeclosertogod.jpg
    rm /var/mobile/LockBackground.jpg

    3. Reboot your iPhone.
    4. Reinstall the SSH package from Cydia.
    5. Follow these instructions to change your default root password and prevent reinfection!

    For known variant D

    1. Run the Terminal app.
    2. Enter each of the following commands followed by “return” to remove these files.

    rm /System/Library/LaunchDaemons/com.saurik.Cydia.Startup.plist
    rm /usr/libexec/cydia/startup
    rm /usr/libexec/cydia/startup-helper
    rm /usr/libexec/cydia/startup.so

    There’s more to the article.

  • I also cant ssh!
    how do you see that you’ve got the ikee worm?

  • leetut

    rm /bin/poc-bbot
    cannot remove no such file or dir!!!!!!!!!!!!!


    still cant ssh using cyberduck
    used to work fine
    sometimes connects but always disconnects and wont reconnect
    who ever invented that virus is a CUNT