Skip to content
Jun 28 / kkrizka

Setup SSH On A Jailbroken iPhone

One of the advantages of having a jailbroken iPhone is that it is possible to setup a Secure SHell server (SSH) on it. SSH gives you access to the underlying Unix system. If you do not know what that means, then probably you do not need it. However, it is a very useful tool for programmers like me. This guide goes over how to setup a OpenSSH server on the iPhone and connect to it from either a Linux, Windows or Mac OS X based computer. In the future, I plan to write a guide on how to setup passwordless login, meaning you don’t have to type in your password every time and still have a level of security.

I originally wrote this tutorial before iOS4 came out, using iPhone OS 3.1.3 running on my iPod Touch 2G. However I’ve also tested this tutorial on iOS4 and none of the steps have changed.

Warning: Make sure to change the default password after you setup the SSH server!!! The default password is ‘alpine’ and is well known. The first iPhone worm exploited the fact that people didn’t change the default password!

Requirements

  • Jailbroken iPhone/iPod Touch. The SSH server is only available through Cydia, since Apple didn’t (and most likely never will) allow it into their App Store.
  • Wireless Router. SSH is a network server, meaning that you need to have it connected to some network. The simplest way to do that with the iPhone is via a WiFi connection.

Setup SSH Server Instructions

  1. Locate Cydia on your iPhone and start it.
  2. Click on the Search tab.
  3. Click on the search bar on top, and type in openssh. There should be only one result, as shown below.  Select it.
  4. Click the Install button in top right corner.
  5. Click the Confirm button and wait.
  6. After the SSH server is downloaded and installed, you can click the Return to Cydia button on the bottom of the screen. Do not exist Cydia yet, because we need to install one more tool.
  7. Now that we have installed the SSH server, we need to install a convenient way to turn it on and off. I prefer to use SBSettings, which is a drop-down menu that allows you to toggle SSH, WiFi and Bluetooth ON/OFF, and lists some useful informations. To install SBSettings, continue from the previous step by clicking the Search button to return to the search menu.
  8. Type in SBSettings and scroll down until you see the entry that just says SBSettings, as shown in the picture below. Select it.
  9. Click the Install button in the top right corner.
  10. Click the Confirm button and wait.
  11. After SBSettings is downloaded and installed, you need to restart your iPhone. This will start up SBSettings. Do so by clicking the Reboot Device button. (On iOS4.0, the button will say Reload SpringBoard. You do not have to reboot your device.)
  12. After your iPhone starts up again, place your finger in the top left corner of the screen, and slide it from left to right. SBSettings will pop down, listing all of the information. The best thing is that you do not have to be on the home screen to do this. You can do it while running any application.
  13. There are two important pieces of information that you see in the SBSettings window. The first is the SSH button in the top right corner. You can click it to toggle the SSH server on and off. Make sure it is in the On position. The second piece of information is the WiFi IP Address. This address is what you use when you connect to your iPhone, so write it down. It will be used in the next few steps.
  14. You can hide the SBSettings window by clicking the X button in the top left corner. The next few steps will show you how to connect to your iPhone from a computer. When you try connecting, make sure that the iPhone is turned on or otherwise it will be disconnected from the Internet. I suggest that you turn Autolock off.

Connecting From Linux

  1. Make sure that you have the SSH clients installed. On Ubuntu, type in the following command.

    sudo aptitude install openssh-client
  2. Connect to the iPhone using the following command. This will connect to the iPhone at IP address 192.168.1.111 (make sure to change it to what you wrote down before) using the root account.
    ssh root@192.168.1.111
  3. You will be asked for a password. If this is your first time logging in, type in alpine. This is the default password, and we’ll change it in the next step.
  4. If you typed in the correct password, you should see a prompt. Any commands that you type in will be executed on your iPhone!

Connecting From Windows

None of the Windows versions come with an SSH client. However there are numerous free options that you can install. I prefer to use the PuTTY client, which is what I’ll be using in the following steps

  1. Download PuTTY from the download page (direct link to 32-bit version). The latest version at this moment is 0.60-beta. The file you should download is putty.exe, which is the program itself. No installation is required.
  2. Find the downloaded program (putty.exe) and double-click it. Take a look at the screenshot below to see what the icon of the program looks like, to make it easier to locate it.
  3. The dialog displayed below should pop-up. Type the IP address of your iPhone into the textbox under Host name (or IP address) label. Also make sure Connection type is set to SSH (should be by default). When you are done, click the Open button to connect. The IP address I wrote into the picture below is different from that you see in the SBSettings picture, because I took this screenshot while connected to a different network. You should still use the IP address that you found via SBSettings.
  4. A dialog box, displayed below, will pop-up asking you to accept a new fingerprint. Just click Yes to skip it. This just means that you haven’t connected to this server before and it wants to make sure that it is the correct one.
  5. You will be asked for a username. Type in root.
  6. You will be asked for a password. The default password is alpine, but make sure to change it after you login!
  7. If everything went right, you should see the prompt as displayed below.

Connecting From Mac OS X

The instructions for connecting to the SSH server from Mac OS X are the same as for Linux. Except you don’t have to install OpenSSH (Mac OS X comes with it) and you type the commands into the Terminal application.

  1. Open the Terminal application by searching for it via Spotlight.
  2. Connect to the iPhone using the following command. This will connect to the iPhone at IP address 192.168.1.111 (make sure to change it to what you wrote down before) using the root account.
    ssh root@192.168.1.111
  3. You will be asked for a password. If this is your first time logging in, type in alpine. This is the default password, and we’ll change it in the next step.
  4. If you typed in the correct password, you should see a prompt. Any commands that you type in will be executed on your iPhone!

Changing Password

  1. Connect to your iPhone following the instructions above. All of the following commands will be run on it.
  2. Lets change the password. Type in the following command.
    passwd
  3. You will be asked for a new password twice. Type in anything you want and hit enter to confirm it. As you type, no characters will appear on the screen, not even *. It is meant to be that way. If you make a mistake, I suggest that you hit the backspace key a lot of times and start typing over.
  4. After you have changed the password, you can disconnect by typing in the following command. Next time you connect, don’t forget to use your new password instead of alpine.
    exit

5 Comments

Leave a comment
  1. hen dos / Aug 1 2010

    Change the root password from “alpine”! Egad, man, I can’t believe you left out that ESSENTIAL step. Else you’re walking around with everything in your phone exposed to anyone on the same WiFi network. This is the original jailbroken-iPhone vulnerability.

  2. Xboxcool / Aug 6 2010

    I just bought a Iphone, this is very useful for me.

  3. Mohammed / Dec 29 2010

    Thank you very much for clear and step by step instruction.

  4. e.groeg / May 26 2011

    Is it possible to assign an IP address so that you can SSH the iPhone thru USB?

Leave a comment