Skip to content

Latest commit

 

History

History
81 lines (56 loc) · 2.38 KB

File metadata and controls

81 lines (56 loc) · 2.38 KB

Share files with SCP

Secure Copy Protocol (scp) sends files over SSH. You can use scp to copy files between your Raspberry Pi and another computer.

Copy files to your Raspberry Pi

To copy a file named myfile.txt from your personal computer to a user’s home folder on your Raspberry Pi, run the following command from the directory containing myfile.txt, replacing the <username> placeholder with the username you use to log in to your Raspberry Pi and the <pi_ip_address> placeholder with your Raspberry Pi’s IP address:

$ scp myfile.txt <username>@<pi_ip_address>:

To copy a file to a specific directory, append the directory path after the : in the scp command. Create the folder before you run scp, since scp won’t create folders automatically. For instance, the following command copies a file named myfile.txt into the project/ directory within a user’s home folder:

$ scp myfile.txt <username>@<pi_ip_address>:project/

Copy files from your Raspberry Pi

To copy a file named myfile.txt from a user’s home directory on a Raspberry Pi to the current directory on another computer, run the following command:

$ scp <username>@<pi_ip_address>:myfile.txt .

Copy multiple files with one command

To copy multiple files, list the file names in a single command, separated by spaces:

$ scp myfile.txt myfile2.txt <username>@<pi_ip_address>:

Alternatively, use a wildcard to copy all files matching a particular filter. The following command copies all files that end with .txt:

$ scp *.txt <username>@<pi_ip_address>:

The following command copies all files that start with m:

$ scp m* <username>@<pi_ip_address>:

The following command copies all files that start with m and end with .txt:

$ scp m*.txt <username>@<pi_ip_address>:
Note

To copy files with names that contain spaces, enclose the file name in quotes:

$ scp "my file.txt" <username>@<pi_ip_address>:

Copy a folder

To copy a folder and all of its contents, pass the folder name with the -r (recursive) flag:

$ scp -r project/ <username>@<pi_ip_address>: