Transferring files with SCP between raspberries

I was playing with Raspberry Pi Model B for quite a long time. Tweaked few settings, wrote couple helper scripts. After some time second Raspberry Pi 2 arrived. I realized that most settings and scripts that were working on previous should do fine on a new one. I needed to copy few files from one Raspberry to another. For this purpose I decided to use Secure Copy (SCP). This is a file sending command over SSH.

raspbery pi

Raspbian OS already come with SCP installed so you can use it right away. (it it is missing you can install it by running command sudo apt-get install scp).

With SCP you can send files in both directions – from local to remote and copy from remote location to local space. Lets get to some practical examples how I downloaded my scripts to new Raspberry pi from another board. My scripts are located in folder /home/pi/myscripts.

The most simplest way is to copy single file. To make things easy to track, connect to both raspberry pi boards via ssh (I use PuTTY). On a destination computer navigate to folder where you want to copy file and run command:

scp pi@ .


pi@ – is a username and IP of remote computer. Then follows semicolon and remote file location. .(dot) at the end is current location on local machine where file has to be copied. When you enter ther command you will be prompted for remote computer password.

If you have lots of files to transfer then use recursive option to copy entire folder like this:

scp –r pi@ .

Here you can see you need to enter source folder which is recursively copied to your local place.

Also you can send files to another raspberry pi. For instance:

scp my.db pi@

This will send my.db file from current folder to remote machine /tmp folder.

There are more handy options to be used with SCP command. For instance “-p” option preserves original access and modification times. If you are transferring large files or groups, you can use compression option “-C”.

More options and information you can find by typing man SCP in ssh.

Leave a Reply

Your email address will not be published. Required fields are marked *