How to SSH to an iPhone (or iPad)

Aug 4, 2011 - 8 Comments

SSH iPhone

You may know already that iOS has the same underlying unix architecture as Mac OS X, and because of this you can SSH into an iPhone or iPad just like you would connect to any other Mac or unix based machine.

As it turns out for us nerdier users, this ability is disabled without a jailbreak, so in order to SSH into your iOS device you will need to jailbreak first. How to do this varies on what version of iOS your hardware is using, but you can find our jailbreak info here or just look for the appropriate version of redsn0w.

To clarify, this is a guide on how to setup the ability to SSH into your iPhone or iPad from another machine, if you are just looking for an SSH client for the iPhone or iPad, Prompt on the iOS App Store is by far the best, and costs $7.99.

How to Setup SSH and then Connect with SSH to an iPhone or iPad

As previously mentioned, the first thing you need to do is jailbreak, that is out of the scope of this article but it’s easy to do. After your iPhone, iPad, or iPod touch is jailbroken, proceed with the following:

Step 1) From the iOS Device:

  • Launch Cydia and search for and install OpenSSH (it’s in the networking section on Cydia) – you won’t see anything on your Springboard because this runs in the background
  • After OpenSSH is downloaded and installed, tap onto “Settings” and then onto “Wi-Fi”
  • Tap on the arrow next to the WiFi router you are connected to, this will bring up the wireless network settings
  • Make note of the IP Address visible on the first screen, as an example we’ll say it’s 192.168.1.103

Step 2) SSH from your Mac or Windows PC:

  • Launch the Terminal in Mac OS X, or PuTTY for Windows users
  • Type the following at the command line:
  • ssh root@192.168.1.103

    Remember to use the IP address you found in the prior step on your iPhone

  • Wait a minute or two while the SSH encryption keys are generated, accept them when (if) asked – this delay only occurs the first time you ssh from a computer to the iOS device
  • When asked for a password, use “alpine” but without the quotes, this is the default password for all iOS devices

Step 3) Change the Default iOS Passwords:
You will now be connected to your iPhone or iPad via SSH. The first thing you’re going to want to do is change the default passwords, otherwise anyone on the network could theoretically connect to your iPhone, iPad, or iPod touch. This is just a matter of typing the following command:

passwd

Provide a new password and then confirm it when asked.

Now you’ll want to change the ‘mobile’ ID password to be safe, this is basically the same procedure:

passwd mobile

Enter a new password and confirm it.

The video below walks through the process of changing the root passwords. This is very easy and only takes a moment.

If you plan on connecting to your iOS device frequently, you may want to set a manual DHCP IP address so that it doesn’t change on you, and then setup an SSH alias so you don’t have to type the entire connection string again.

SSH into your iPhone from the iPhone (or iPad to itself, etc) ie: Connect to localhost:
For connecting to localhost from your iOS device, you just need to have an SSH or Terminal client on the iPhone itself. Again, I’ll suggest Prompt from iOS App Store, but there are other options out there.

SFTP to the iPhone or iPad:
Transferring files to the iPhone or iPad is just a matter of using SFTP after OpenSSH has been installed and is running. You’ll use the same IP address, login, and password as connecting with SSH, just from an ftp client instead of the Terminal. A few good free FTP clients are CyberDuck for Mac, or Filezilla for Mac, Windows, and Linux.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: William Pearson in Command Line, iPad, iPhone, Tips & Tricks

8 Comments

» Comments RSS Feed

  1. xf says:

    ssh localhost

    done

  2. [...] of things, from adjusting bandwidth settings on a router, to transferring files directly, to using SSH to connect to an iPhone. stLight.options({ publisher:'fe5e0a84-1fac-40de-8014-9f89fc1cbe6a' [...]

  3. [...] This means iMessage can be used as a simple method of moving any files to an iOS device without using SSH and SFTP, although the destination folder of these files creates some [...]

  4. josh says:

    alpine password will not work for me…..

  5. leetut says:

    ssh root@192.168.1.*** timed out?????

  6. [...] the Terminal or your preferred SSH client, find the iOS IP address, and connect to the iPhone using SSH [...]

  7. [...] this command after you have used SSH to connect to the iPhone, it will rename the shutter sound effect, thereby preventing it from sounding at all: mv [...]

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates