Smart Cities - Transferring Files using Secure Copy
Introduction
- The fastest way to copy files between two computers is to use Secure Copy (scp)[1].
- This method is executed from the Terminal and hence eliminates the overhead of a GUI application.
- It is both fast and secure.
- Files can be transferred in both directions.
Prerequisites
- In this lesson it is assumed that Secure Shell (SSH) has been enabled on both computers.
Enabling SSH on a Raspberry Pi
- In the Terminal enter the command sudo raspi-config
- In the raspi-config menu select Interface Options
- Select SSH (Secure Shell) and then select Enable SSH
- SSH will now be enabled. There is no need to reboot the computer.
- Exit raspi-config
Copy File From Local Host to Remote Server
- In this example we will copy a file from a local host computer to a remote computer on the same network.
- 192.168.1.105 Local computer IP address
- 192.168.1.120 Remote computer IP address
- On the Host computer create a new directory named test with the command mkdir test
- Enter the directory using cd and create an empty file named file_to_send.txt with the command touch file_to_send.txt
- To send the file enter the command scp file_to_send.txt pi@192.168.1.120:/home/pi/
- You will be asked to enter the pi user password on the Remote computer
- The file will now appear on the Remote computer in the /home/pi directory