How to Use SSH to Transfer File on iPhone

by Simon Ng on May 17, 2009



OpenSSH for iPhoneIf you ask me the top reason for jailbreaking iPhone, the ability to use SSH to transfer files between iPhone and computer via WiFi is my answer. I believe it’s also one of the reasons why some of you go for the jailbreak. But, as I know, not all the readers are geeks and come from technical background. You may even not heard of SSH until you decide to jailbreak. So, here is a short guide to show you how you can use SSH on iPhone and use it for transfer any files to your computer (Mac / Windows). The guide is completely target for non-technical person. I just want to show you how great SSH is when pairing with iPhone for wireless file transfer. So, you can use it to transfer ringtone and photos without the USB cable.

So, what’s SSH?

The first thing you would like to know is what SSH is. SSH stands for secure shell that is commonly used in Unix/Linux environment. You can use SSH to access a remote a computer and execute commands from another machine that may be miles away. Additionally, you can use it to transfer files to the remote computer, just like FTP. I’m not going to dig deep and throw out all the technical details about SSH. But just remember, SSH is a tool that lets you access machine or devices remotely. Here, the device is your iPhone.

Installing SSH on iPhone

You may be curious why you can use SSH on iPhone. Is SSH just designed for Unix? That’s a good question. You may not know the iPhone OS is a stripped-down version of Mac OS X, which is actually riding on Unix as its core. So, that’s why you can use SSH on iPhone.

But officially, Apple didn’t bundle the utility for every iPhone user and thanks to the jailbreak community to bring SSH to iPhone. As long as your iPhone is jailbroken, you can install and use SSH on iPhone.

To use SSH after jailbreak, you can go up to Cydia and search for “OpenSSH” to find the package. Tap the Install button to install it on your iPhone. Once installed, restart your iPhone. You’ll not find an icon for SSH on the home screen. But after restart, the SSH tool will be automatically launched and listens for remote request in background.

OpenSSH in Cydia

Note: Did you set the auto-lock? Your iPhone should be turned on during the SSH file transfer. So, if you have configured auto-lock, I suggest you to disable it before using SSH. You can go to Settings -> General -> Auto-Lock and set it to Never.

How to Transfer File Using SSH

Okay, here comes to the core part of this guide. How can you transfer file to & from iPhone remotely with WiFi? Now, your iPhone is already enabled with SSH and listens for incoming SSH request. Before you can transfer file from your computer to iPhone, you have to know the IP address of your iPhone.

To check for the IP address, go to “Settings” -> “Wi-Fi”. Tap on the connected WiFi network and view the details. You’ll see the IP address of your iPhone. Say, for my case, the IP address is 10.0.1.5.

iPhone WiFi IP Address

Once you know the IP address, the next step is to connect to iPhone from your PC or Mac.

For Windows User
For Windows users, I highly recommend you to download WinSCP, which is a free SSH client for Win XP/Vista. You can download it for free from here.

Installation of WinSCP is very straightforward. Just double-click on “winscp421setup.exe” and follow the instruction to install it on your PC.

Once complete the installation, launch WinSCP and click “New” to connect to iPhone. In host name, type in the IP address of your iPhone. For user name and password, you can use “root” and “alpine” respectively. Keep other fields unchanged. You can then click “Login” to start making connection with your iPhone. Click “Yes” if you’re prompted with a warning to add the host key to cache.

Tip: Instead of clicking “Login” directly, you can click “Save…” to save the connection profile for future use

WinSCP - New Connection

WinSCP - SSH Prompt

When connected, you’ll see the files in iPhone file system. And, you can easily transfer files between iPhone and computer by just drag & drop the files in WinSCP.

WinSCP - Connected with iPhone

For Mac User
Mac is SSH-friendly. There is already a SSH client bundled inside Mac OS X. But you can only use it in command mode only as it does not offer a graphical interface. So, I highly recommend you to download a free SSH client called “Cyberduck” to connect to iPhone. You can download Cyberduck via this direct link or via its homepage.

To transfer files to iPhone, simply launch Cyberduck and click “Open Connection”. Then fill in your iPhone’s IP address in “Server” field. And use “root” and “alpine” for user and password respectively.

Cyberduck - Open Connection

Next, click “Connect” button to connect to iPhone. And, Cyberduck will start establishing connection with your iPhone.

Make sure your iPhone is turned on. Otherwise, your Mac will fail to make the connection.

Once connected, you’ll see the folder list of your iPhone file system. You’re free to navigate through the file system. To download file from iPhone, just right-click on any file you want to download and select “Download To..” to retrieve the file. And, to transfer file back to iPhone, simply go to the destination folder and right-click to select “Upload”. That’s it!

Cyberduck - iPhone Connected

Further Information

I hope this guide is helpful for you and you can find SSH useful for iPhone. Now, to further enjoy the benefit of SSH, you can check out the following guides:

Do you find any problem with SSH? Feel free to leave comment and share your experience.

WARNING: It’s highly recommended you follow this guide to secure your jailbroken iPhone (with SSH enabled) from virus attack!

 Share with Your Friends

What's Next?

If you find the post is useful, subscribe to Simon Blog using RSS or Email to get free iPhone updates. Alternatively, you can follow me on Twitter or join us on Facebook.

Related Post you'll like:

Sign up and Download Free iPhone Guide

{ 5 trackbacks }

Howto disable A2DP on the iPhone « Ramon’s weblog
August 20, 2009 at 3:44 pm
Using SSH on Iphone to Upload Ringtones and SMS Tones «
October 8, 2009 at 12:15 am
Visoška kronika » Komu zvoni?
October 14, 2009 at 11:51 pm
com3.es | Use WiFiPhoto To Transfer iPhone Photos to Computer Wirelessly
December 12, 2009 at 7:10 am
How-To Crack Official AppStore Apps using Crackulous. - iPod Touch & iPhone Modding
January 22, 2010 at 6:08 am

{ 60 comments… read them below or add one }

1 Javier Gil May 18, 2009 at 4:17 am

hi…… and how do you change permissions for the files??? (ex. 777etc..)

Reply

2 Dusty May 18, 2009 at 9:56 pm

@Javier Gil
Yo! Right click on the file, scroll down to properties/CHMOD. Once clicked, a new window will open up and u will see permissions [xxxx] Change the permissions to correct number and hit apply or ok.

Good job on the How To Simon!

Reply

3 Nam Luu May 19, 2009 at 6:15 am

Hey Simon, thanks for the great how-to. However, I think it’s still too difficult for most ppl. I tried SSh my iphone once when I first jailbreak it but I got tired of the tedious process.
There’s a simple solution to this. I dont know if you ever heard of “iphonebrowser.” It’s a great opensource app that lets you access your iphone sans all the setups that are required for SSH.

Pros:
Plug, Run and Play. No more preliminary steps.
Fast transfer speed (over USB cable)
Easy for everyone, no need to write a guide for it.
Preset Directories: Wallpapers, Pictures, DCIM photo, UI Sounds, Ringtones, Theme folder etc.

Cons:
No wireless transfer (must use USB cable)
changing permission? (I never change permission so I dont know if it’s there or not)

Let me know if you find Iphonebrowser worthy.

Reply

4 Nam Luu May 19, 2009 at 6:18 am

I forgot one best Pro:
you get to access/transfer files in the background even when the phone is locked. How cool is that.

Reply

5 sam June 26, 2009 at 10:32 am

Hi Simon,

After upgrade, jail break and unlock i am not able to install openSSH, installer, video recorder is installed but not able to open it and not able to load lots of applications which was there already.

As well as could you please reply me i am getting lots of error messages while installing any kind of application.

Regards

Sam

Reply

6 nougiw July 2, 2009 at 7:28 pm

Me too. Just like sam. I’m getting error messages for almost anything I try to dl and install form cydia. Even some essential updates it says I should dl or else I’m going to have problems. Particularly for SSH it gives me a “couldn’t configure pre-depend dpkg for ncurses, probably a dependency cycle” error. Any help or ideas? Thanks…

Reply

7 Robert December 6, 2009 at 11:10 am

Hi Simon,

Everything went fine until….. I did the jailbreak and installed openSSH using Cydia and then installed Cyberduck on my Mac. Then went to open connection after retrieving the ip from the iphone and using root and alpine got connection failed. Not sure why. My mac is connected to a home network and the iphone uses that without any issues

Reply

8 Nicole August 13, 2009 at 5:17 pm

i did exactly as you wrote but i end up with network connection time out?
any ideas on how to fix this?

Reply

9 Simon Ng August 14, 2009 at 1:30 am

@Nicole, looks like your iPhone is not enabled with SSH. If you’re sure you have installed OpenSSH, try to restart your iPhone and try again.

Reply

10 Charles August 25, 2009 at 9:11 am

“You may be curious why you can use SSH on iPhone. Is SSH just designed for Unix?”

Many LOLS…

SSH is a protocol. It has NOTHING to do with UNIX/LINUX. It is the secure replacement for Telnet. Like any protocol it is used for communication and is not OS specific, even though most bare bones Linux kernels support it. I realize you’re trying to dumb this down for the average Mac users (read people who can’t use a toaster sans epic fail unless Steve Job’s puts an i in front of it).

While I have an iPhone, the first thing I did was jailbreak it. One thing I couldn’t stand about Apple in the 1980’s and now is their insane level of control over everything you can do on your Mac/iPhone/iPod. It’s ridiculous, and they’ll never change. They’re like the “Pied Piper” stringing people along with promises of a better experience as long as you assimilate to their domination which is why the Linux/Windows market will always prevail. Linux may be a bit behind the curve in friendliness, and Windows has struggled, but both are catching up to Macs, especially Windows with the WPF initiative.

Reply

11 Claus September 5, 2009 at 1:43 am

Hi .need help .have a 3gs. Have one pc with xp professionel where my iphone can wifi connect with winscp and openssh and ex internet explorer and discover app but a vista and xp home edition where nothing works but my old first generation works with all pc. What are my two computers missing to be able to communicate with my 3gs?

Reply

12 Simon Ng September 5, 2009 at 1:57 am

@Claus, to use SSH for file transfer, you need to jailbreak your iPhone 3GS first. So, are you using jailbroken iPhone? If yes, you can install OpenSSH via cydia and then transfer file via SSH.

Reply

13 Claus September 5, 2009 at 5:06 pm

Hi simon. Thank you for answering. I know that and is jailbroken like my first generation iphonw. But the new 3gs do not reply always maybe one in 100 atemts. Grt timeout. Also with cable and tunnel program. Also no reply when use free ftp apps like discover and try to contact with filezille or IE. Like my phone wont answer. If i am lucky an get connection the wifi is extremly slow or the connection stops short after with time out . Turned off autolock and installed keep wake no improvement. There is no iphone support here in denmark and have had it to repair but they said nothing wrong. I do not know what to do. Can use wifi and can easily downloadand stream also from my own media server. Itseems that it is only when my iphone my reply there is problem and suddently it works but very very slow few kb pr sec. But iphone browser i found on internet works perfect with cable on all my pc but i dont think the phone need reply with this. Sorry i am a noob and not good with this why it might sound strange when i tri to explain. Claus

Reply

14 Simon Ng September 9, 2009 at 12:31 am

@Claus, did you try to reset the network setting? You may check out this post and see if it can resolve your wifi issue.

Reply

15 allen September 7, 2009 at 7:08 pm

hi what do i download on to my i phone once i have jaol broke it so i can get free apps on it.

Reply

16 Dusty September 7, 2009 at 9:35 pm

Google.com

That is way off topic for how to SSH and I don’t believe Simon would prefer that to be discussed here.

Use the App Store and support devs to get your downloads for apps and games!!!!!!!!

Reply

17 Dusty September 7, 2009 at 9:36 pm

O ya, its also called Jailbreak, Jailbreaking or Jailbroke iPhone for helping u on ur searches ;)

Reply

18 Claus September 8, 2009 at 2:19 pm

Nobody thathas experiances what i wrote two days ago? 3gs with 3.01. anyone know a website that might help with issues where things just not work? I need more than a recipe for how it should work. Need some expert advice andno one here in denmark. Just blogs which again shows how it should work no experts when there are problems. Hope for some assistance.

Reply

19 vijaya ragha rao January 15, 2010 at 7:39 pm

plz try iphone haking site or redmondpie site to get solution

Reply

20 Claus September 9, 2009 at 9:48 pm

Have reset and restored Multple times and downgraded to 3.0. No change at all.

Reply

21 chris September 23, 2009 at 1:16 pm

hi. i used this tutorial to transfer a .pdf into my iphone. everything went fine. but when i went to open this file via fileviewer, which i got from cydia, i get this:

error:
operation could not be completed.
(webkiterrordomain error 101.)

anybody know how i can open and view this .pdf on my iphone?

thanks.

Reply

22 Simon Ng September 24, 2009 at 12:50 am

@Chris, you can download “File Share” or “Good Reader” from App Store. Both applications can let you read PDF on iPhone.

Reply

23 chris September 23, 2009 at 1:16 pm

oh yeah…it’s a 2g with 3.0 firmware.

Reply

24 chris September 26, 2009 at 12:36 am

thanks a bunch simon ng. much appreciated.

Reply

25 Sergio October 5, 2009 at 4:45 pm

А если посмотреть на это с другой точки зрения то не все так гладко получается

Reply

26 maninder October 7, 2009 at 8:59 pm

Have a jailbroken iphone 2g 2.1 .. i don’t seem to be able to connect thru ssh using winscp or putty.. it tells me “software cause connection to abort” .. Have tried using wifi and via USB as well .. further am using itunes 9 ..
I have installed openSSH on the iphone 2g and ssh is active on it.. further I have the IP of the phone correctly
PLS HELP ..maninder

Reply

27 Manuel Paz October 16, 2009 at 5:53 am

hi !!! i have a mac… how do i change the permissions ?

Reply

28 Jim November 3, 2009 at 9:28 pm

Please, please, please append the post to warn people that they should change their passwords for both accounts (root and mobile) after installing SSH. Again (not for the first time) someone has broken into a range of iPhones over the 3G network, using the default password: see http://arstechnica.com/apple/news/2009/11/dutch-hacker-holds-jailbroken-iphones-hostage-for-5.ars

Unfortunately, most SSH tutorials fail to mention this. Yours is one of the first to turn up in a Google search for ‘SSH iPhone’, so it’s important that you warn your readers.

Reply

29 Simon Ng November 12, 2009 at 5:11 pm

@Jim, thanks for your suggestion. Now it’s advised to follow this guide to secure the jailbroken iPhone once SSH is enabled.

Reply

30 Doug November 4, 2009 at 6:14 pm

Speaking of changing the SSH password, in Cydia, there is a nice step by step tutorial. Go to the main menu, scroll down, go to “OpenSSH Access How-To”.

Follow the steps if you haven’t already installed SSH. If you have, then scroll down, and there’s another arrow taking you to “Change default password.” And follow those instructions.

Alternatively, install OpenSSH.
Get your iPhone’s ip address
Open Terminal
Login to your iPhone using “ssh root@
Accept the host key if you are asked
login with password “alpine”
type “passwd”

you will be asked for a new password, but the cursor won’t respond as you type in, so be careful.

you will be asked to repeat the password. again, be careful

all done

Reply

31 Simon Ng November 12, 2009 at 5:11 pm

@Doug, thanks for the great tips!

Reply

32 Jim Frogge November 5, 2009 at 8:47 am

Another Thanks for the know-how show-how! This is great and again your directions are right on!! Thanks again!!
jim frogge in NC!

Reply

33 Sina November 11, 2009 at 5:51 am

Heyy thanks for the tutorial but i jsut have a problem

i have a jail broken iphone 3gs with a wifi connection at home
and i have tried doing the sssh root@(ip-address) thing on “Terminal” on the iphone and it will connect like that but when i do it with WinSCP on my windows Vista Computer it always says that the connect was time-out and i have installed openssh because i can see in both icy and cydia that the program is installed but when i robooted my iphone no ssh program or anything opened up so im very confused :(

any help please?
Thanks alot in advance :)

Best Regards Sina

Reply

34 cena December 4, 2009 at 5:13 am

wow.. that was easy then expeced… thanks

Reply

35 Sharma December 8, 2009 at 2:48 pm

I can use openssh to do file transfer. But it works only for a while, say for a few minutes. Than the server unexpectedly terminates the connection. Thus I have to reinstal openssh every time to get the connection. Have already changed the password. Is there a way out. Please help.

Reply

36 Jim December 8, 2009 at 4:59 pm

Keep the phone ‘awake’ (don’t let it lock). But anyway, this can happen; I get it too. You don’t need to reinstall OpenSSH. If you install any of the programs that can close and restart OpenSSH, that will be enough. For example, SBSettings has a toggle for SSH. It can quickly turn SSH off and back on, so the connection can be established again.

Alternatively, turning the phone off and on again will work. You can also try a solution using the USB cable (iTunnel, iPhone Tunnel Suite) though I’m not sure whether there is currently a working version.

Reply

37 Sharma December 8, 2009 at 9:12 pm

Thanks Jim. I tried all these. Kept the auto lock on “never”. Used BossPref to turn openssh on and off. Also putting the phone off and on. However, it works only on reinstall and that too for 3 to 5 minutes. Will try itunnel now. But would be grateful for any solution with wifi.

Reply

38 Jim December 8, 2009 at 9:26 pm

Sharma, I suggest you create an account at the hackint0sh.org forum and see if you can find a thread there about this problem. I’m almost sure they exist and you can add a post to one of them asking for help. It is a forum where the most knowledgable technical jailbreak-people are posting.

Reply

39 naomi December 22, 2009 at 6:17 am

i have a mac and i cannot open cyberduck…..when i double click it it appears in the dock and it bounces…and then dissapears…can anyone help me please?

Reply

40 Ross December 26, 2009 at 9:50 pm

Hi Guys

I have successfully copied the files over…now how do i run them (apps) It would appear the only app to extract apps installed this way is called “installulouss”…but as far as i can see you can no longer download it. I have no way of accessing the files i have copied over?

Thanks

Ross

Reply

41 dom December 27, 2009 at 1:52 am

watsup guys im on windows xp and when ever i try to ssh ill add all my information into winscp and when i click login a white screen just pops up ive re downloaded and re jailbroken my iphone 3gs and nothing seems to work. please help i miss being able to ssh and get into my iphone :[ thanks

Reply

42 Dave December 29, 2009 at 1:28 pm

Hi Guys,
I’m new to this, jailbroke my 3GS 3.1.2 using blackra1n. Worked fine. I failed to install openssh when my Cydia was working. Last night my Cydia opens breifly, says loading data, and closes. I can’t get into Cydia. Can’t install openssh without Cydia, Do I need to restore my phone, or is there a way to install openssh without Cydia or re-install Cydia without SShing?

Any help would be appreciated!
Thanks
Dave

Reply

43 Jim December 29, 2009 at 9:25 pm
44 Charlie January 4, 2010 at 2:10 am

If your iPhone is jailbroken, and you are running Mac OSX, you can also install “Netatalk” along with “OpenSSH” from Cydia. With Netatalk installed as well, your iPhone will show up as a device in the finder, making this process even easier, because you will not need any additional software.

Apple Products work perfectly… together

Reply

45 Mark January 6, 2010 at 4:02 am

My Cyberduck also bounces once then closes, but only if I open it from my Applications folder. If I move the Cyberduck file into, say, my downloads folder, it opens fine…

Reply

46 Alex January 17, 2010 at 12:50 pm

hi, i installed openshh on my iphone. and downloaded WINscp. but when i try to login in it just keeps asking for my password and saying access denied. but i have the right password..

Reply

47 Owen January 20, 2010 at 6:57 am

Just a note for anyone trying to transfer photos via SCP, and is wondering how to generate the .THM thumbnail files so you don’t have a page of black in the photo album (it took me ages to work this out!)

The .THM files go in a folder entitled .MISC, which resides in the same directory as the photos. If you’re using linux and have Image Magick, a simple shell command to make the .THM files is:

for i in *.JPG; do convert $i -resize 240 -crop 160×160+40+0 .MISC/`basename $i .JPG`.THM; done

Hope this helps someone …

Reply

48 vietdo January 25, 2010 at 3:30 pm

I’ve got the window vista, netframe 3.5, itune 9. My iphone firmware’s 3.1.2. When i try to putty to my phone and got the message: connection refused. Then, I tried this command on mobile terminal ssh root@127.0.0.1 then got the message: connection closed by remote host. Do you think iphone itself lock the connection to host? any help much be appreciated. Viet

Reply

49 Jim January 26, 2010 at 2:01 am

127.0.0.1 is not the right address. See the details of your wifi connection (in Settings… Wi-Fi…) for the right address.

Reply

50 vietdo January 26, 2010 at 10:35 am

You mean with mobile terminal, I can only ssh to iphone with wifi setting? Normally, i connect iphone to computer by usb cable and thought 127.0.0.1 is default address. I will try with wifi to see the difference. thanks

Reply

51 vietdo January 26, 2010 at 11:07 am

I’ve tested with wifi. It’s also the same result “connection close by remote host. Any help

Reply

52 Jim January 26, 2010 at 11:12 am

If you ssh into your phone through the USB cable, you need to have iTunnel running on your computer. Why you’d use MobileTerminal on your phone to make an ssh connection to itself I don’t understand. You’re already logged into the phone once you have started MobileTerminal on the phone…

Reply

53 vietdo January 26, 2010 at 8:03 pm

Dear Jim,
It might be silly when i tried to connect to itself. Because I just want to test openssh work or not on iphone. Could you tell me why i need itunnel running on my computer? which version of itunnel should i install now?

Reply

54 Jim January 26, 2010 at 8:17 pm

iTunnel allows your computer to ’see’ the phone through the USB cable as if it’s a device on the local network, at address 127.0.0.1 on port 22 (or any other port you specify when launching iTunnel). Once that is achieved, PuTTY can make an ssh connection to that address.

I think iTunnel is now at version 9. You may also need to copy a .dll file from one of iTunes’ program directories, and you probably need a recent version of iTunes with which you have already connected the phone. Google will provide more instructions.

That said, if your computer and your iPhone are on the same local network (e.g. the computer is 192.168.100.2 and the phone 192.168.100.3), PuTTY should normally be able to connect to root@192.168.100.3 on port 22. If not, maybe your router doesn’t allow connections between its clients. That can usually be changed in the router’s settings.

Reply

55 Sean January 26, 2010 at 9:57 am

i am also having the issue where its telling me that i dont have the correct password any help would be greatly appreciated for me and the other poster above me thanks

Reply

56 vietdo January 26, 2010 at 10:36 am

if you don’t change the password, just login by root, password is alpine. It’s default setting.

Reply

57 Sean January 26, 2010 at 10:44 am

thanks for the quick reply bro

Reply

58 Nipun jain January 26, 2010 at 5:01 pm

dude i try to download open ssh but cant … it says “Http://apt.saurik.com host unreachable.” and also can u tell me how can i disable APN without doing SSH or any thing complicated . something simple would be great!

Reply

59 Sai January 27, 2010 at 9:41 am

I coudnt get the password to work

Reply

60 Nick January 27, 2010 at 6:48 pm

Tried to set up an SSH connection, but ran into a problem:

I/O Error: Connection failed
sftp://192.168.1.11
There was a problem while connecting to 192.168.1.11:22

Any Help?

Thanks.

Reply

Leave a Comment

Previous post:

Next post:

Get smart with the Thesis WordPress Theme from DIYthemes.