How to SSH / SFTP: A Walkthrough for Mac Users

Posted by Nic Elder on: August 5th, 2008, 12.03 pm

Chances are that if you’ve followed one of our tutorials to jailbreak your iPhone, you might need some help on how to get files on and off.  One example of where this might be needed is putting NES Roms on the phone for the NES app that’s available in Cydia.

In this article I will walk you through the entire process of copying files to the iPhone using Mac software. A separate Windows tutorial will be available shortly for non-Mac users — fear not we haven’t forgotten you!

A few things are required to be able to follow this tutorial:

  • iPhone/iPod must be jailbroken (see mac or windows tutorials for help)
  • Download an FTP Client  (see note below for a list of clients)
  • iPhone/iPod must be on WiFi (no Edge or 3g for SSH/SFTP)

NOTE: For this tutorial you will need an FTP client that is capable of transferring files using the SFTP protocol.  For Mac users we recommend Fetch ($15 / 15 day free trial).

Walkthrough:

1. Download OpenSSH from Cydia (see this Tutorial for help)

OpenSSH is the server that will run on the iPhone that allows us to connect using SSH or SFTP applications.  Downloading OpenSSH will not add any icons to your SpringBoard as it runs in the background.  In the next step we will download an application that will allow us to turn on and off OpenSSH when it’s not in use.

2. Download Boss Prefs from Cydia

Boss Prefs lets you control different settings of the iPhone/iPod without having to go through all of the settings menus.  It also lets us turn SSH on and off easily.

3. Open Boss Prefs / Enable SSH

Boss Prefs has a few switches — SSH is probably already turned on, but open Boss Prefs just to make sure.  WiFi may show as off (even if turned on), go ahead and flip the switch to ON, your IP address will be shown in parenthesis next to the WiFi switch.  WRITE DOWN THIS NUMBER, you will need it to connect to the iPhone/iPod in the next few steps.  (In our screenshot the IP address is the 192.168.1.115 number you see next to WiFi below)

4. Set Auto-Lock to Never

SSH / SFTP sessions require that the phone be connected to WiFi.  When the phone locks, in order to save battery, it temporarily shuts off the WiFi connection.  Because of this we’ll disable Auto-Lock on the phone for the duration of our session.  You might want to re-enable it after you’re done transferring files.

5. Create an SSH session to the iPhone / iPod

Open up your SSH Client and connect to the phone.  The first connection will take 15-30 seconds as the phone will need to generate a security key.  This is normal. If your SSH Client times out, try connecting again, and your iphone will likely have finished creating the key by the second attempt.

Mac Users use Terminal.app which is built in to the Mac OS

Connect to the iPhone using the address you recorded in step 3

After 15-30 seconds type ‘yes’ when asked to accept the new key

When prompted for a Username type ‘root’
When prompted for a Password type ‘alpine’

You can now type exit and close Terminal.app

6. Create an SFTP session to the iPhone / iPod

Now that the phone has all the required software, and we’ve generated our security key, we can begin transferring files to (and from) it.  For the purposes of this tutorial we’ll show you how to accomplish a common request, putting NES Roms on the phone.  First, let’s connect to the phone using our SFTP client.

For Mac Users:

Open Fetch

Create a connection to the iPhone using the address from step 3
Use the username and password in step 5 above (root / alpine)
Make sure you select “SFTP” in the Connect Using box

After connecting you will be placed in the folder
/var/root/

When opening the NES app on the phone it tells us we need to put ROM files in the
/var/mobile/Media/ROMs/NES folder

Click Path to change to /var

From /var click through mobile, then Media

You will notice there is no ROMs folder inside of the Media folder, so we need to create it
Click +New Folder to create a folder
Type ‘ROMs’ (Case sensitive) in the new folder dialog

In the ROMs folder we need to create the NES folder
Click +New Folder
Type ‘NES’ (Case sensitive) in the new folder dialog

‘Put’ your .nes file in the newly created folder
Click ‘Put’
Select your rom file (must end in .nes)

7. Disable SSH and turn on Auto-Lock

Now that you’re finished with your SSH connection you can shut it off.  This will free up some memory, as well as keep unwanted connections from being made to your phone without your knowledge.

7. Open NES and enjoy your new ROM file!

Summary

Though we used NES emulator as a basis for this walkthrough the steps may be applied to a lot of other tasks.

Some other uses for SFTP on the iPhone are:

  • Manually installing applications not available in Cydia
  • Transfer voicemail from iPhone to a computer (see this article)
  • Removing unwanted applications from the iPhone / iPod

You also have the ability to create a terminal session with the iPhone.  From within terminal you can change permissions on files and folders, delete files, edit preferences, and various other things.

Some key things to remember when following this tutorial:

  • Set Auto-Lock to Never
  • Remember IP Address from Boss Prefs
  • Username and Password are case sensitive
  • Username is: root
  • Password is: alpine
  • Turn off SSH in Boss Prefs when done
  • Turn on Auto-Lock when done

If you need help, ask questions in the comments below!

19 Comments

  1. Does Somebody know a way, to install Installer 4.0 with a PC ??

  2. how do i use this with the cydia “file viewer”

  3. @sam: I’m not sure what you mean by the cydia “file viewer” ?

  4. it an app in cydia, u no d program sorta like installer, it sais it lets u view pdf’s and stufff, but it need like u no d var/…/….. names 4gotten wot they r called. but anyways maybe u shud check cydia

  5. exists a ssh “client” for iphone? via term? so i could rmote another machine?

  6. Whenever I use terminal to try to connect my iphone and what not, it always times out. I don’t understand why. My phone is connected, SSH is turned on on my iphone, I’m using wifi, the IP address is correct, everything. But it keeps timing out.

    Can someone help me get a connection?

  7. @Allyson: Have you turned off autolock and left the phone on the homescreen? When the phone locks it turns of WiFi to save battery.

  8. I appreciate your help, Nic. However, I did turn off autolock and left my phone on the home screen, but terminal still did not connect to my phone. After typing the IP address in terminal, I press enter/return, right? I don’t understand why it’s not working.

  9. I just wanted to say thank you for your help! But I got it to work. :D
    I switched to another mac and used a different wifi network.
    All of a sudden it worked! But thanks for the help. :]

  10. Legend of Zelda Octorok Hunter – Made this mettlesome in a some days, ease employed on it :) The neutral is to blackball every adversary as alacritous as possible

  11. It is a major security hole if you enable SSH on your iphone and have a known root password. Anyone on the same network can login with the known root password “alpine”. It would be best to either include steps on how to change this, or at least identify the security hole is there.

  12. I too have this error, i think it involves the authorization key perhaps
    as i can ssh fine the first time
    but the next day i get time out errors
    and turning ssh on and off or the phone on and off
    over no help
    I had this problem awhile back and I forgot how to fix it
    and the net is just full of people saying
    did you install openssh? did you turn off autolock, etc..
    I have done all these things
    there is obviously a deeper bug here that no one is addressing

  13. How do u uninstall a program from installer 4.0 I tryed to hold my finger so I can x it but doesn’t work and in the installer u can’t find it. If any know please tell me.

  14. at the terminal stage, I follow the instructions and I get this:

    macbook-pro:~ Dah$ ssh root@192.168.1.2
    ssh: connect to host 192.168.1.2 port 22: Connection refused

    Thanks…

  15. where can i find in iphone ROMs files? Thank you

  16. Ehm, where did you get that specific NES ROM for super mario? Benn looking for it all over the place… Thanks, Pilopew

  17. this is annoying, none of these tutorials tell me what to do exactly, because the SFTP client wont connect to my phone, i installed OPENSSH and all that stuff and it says the connection was refused ;_;

  18. another use for this is to get apps on your buddy’s iphone which he paid for and install it on your iphone for free.

  19. I’ve tried this with Fetch, Cyberduck and Fugu and have never been able to create a connection. I use Wi-fi and have noticed that the address has changed on 2 separate occasions. Weird. Is this a common issue? Please help me sort this out

    thanks

Leave a Response