Tuesday, 11 March 2014

Remotely copy files to and from your Raspberry Pi.

Most of the time I remotely log into my Raspberry Pi. Depending on what I am doing I will either SSH into it or VNC into it, which allows me to do almost whatever I would like to.

I say almost as there is a caveat.

What happens when I want to transfer a file to or from the Raspberry Pi?

I have to find a memory stick, plug it into my computer, copy the files onto it, unplug it, plug it into my Raspberry Pi, go back to my computer, copy the files over...

Then if I happen to modify a file and want to transfer it back I go through the whole process again.

What an absolute pain!

There must be a better way... Well you will be pleased to know there is!

The secret is using SSH File Transfer Protocol or SFTP. (SSH stands for Secure Shell.)

Once you know how to use this, and it really is simple, it opens up a whole world of really cool options.

Lets start simple, and work out how to transfer files to and from your Raspberry Pi.

There are a number of programs you can download to help you out with this, but if you are new to this, I recommend FileZilla.



You will want the client and not the server version. You can download it from this link.


There is a version for Windows, Linux and Mac OSX.

Once installed, load the program. You should see a screen like this.



Now click on File and then Site Manager.



Now you should click on New Site and make the following changes:
  • In the entry box next to Host type in the IP address of your Raspberry Pi. If you are unsure of this, you can follow an earlier blog post of mine which helps you to determine this. 
  • Protocol should be changed to SFTP - SSH File Transfer Prototcol.
  • Logon Type should be Normal
  • Type in your User name in the box below this
  • Your login Password goes into the box below. 
  • Using the Rename button I have renamed my connection to Raspberry Pi. You dont have to do this, but it helps you identify your connection.
Your screen should look something like this.



You can now click on connect.

You may get a message warning you that the server's host key is unknown. You can just click OK if this box appears.

Your FileZilla window will now look as follows.


On the left hand side you can see under the Local Site there is a window which shows you the folder structure of your system. Underneath that there is a window which shows information of the files and folders of any folder you chose in the folder structure.

This is repeated on the right hand side but for the file / folder structure on the Raspberry Pi.

To transfer files to you Raspberry Pi

  • Navigate to the folder you would like to place the files into using the right hand windows. 
  • Navigate to the files or folders you would like to copy over in the left hand windows. 
  • Right click on the files or folders and chose "Upload"
The file will start to copy over to the selected folder. 

A similar process is used to transfer files from your Raspberry Pi.

  • Navigate to the folder you would like to place the files into using the left hand windows. 
  • Navigate to the files or folders you would like to copy over in the right hand windows. 
  • Right click on the files or folders and chose "Download"

This will copy files from your Raspberry Pi.

In the future your information should be saved into FileZilla, so you can just click on File then Site Manager, select the Raspberry Pi connection you have set up and then click connect. Simple!

I am sure a lot of you will find the use of SFTP very simple but effective, and you will no longer be searching around for a memory stick to copy files to your Raspberry Pi.