SCP (Secure Copy) is a command-line utility included with most Linux distributions enabling secure file transfers between two networked systems. It uses SSH for authentication and encryption, ensuring transferred files and passwords are protected against unwanted access.
In this guide, we detail basic SCP syntax and how to use secure copy for remote transfers. You’ll need to have set up SSH for your VPS to use SCP.
As with most command-line utilities, SCP has a lot of different options. Understanding syntax can fast track your understanding and ability to use it effectively. Below is the most basic example of SCP syntax with a detailed description about each section.
scp [options] source destination
From the start, scp is followed by:
There are a number of useful options that you can apply to your SCP command to control its behaviour some of the most relevant include:
-P
-p
-q
-C
-r
Copy files and/or directories (with -r) from your local device to a remote system using a similar command to below. Which copies that index.html file to the remote systems public_html directory.
scp /path/to/index.html root@192.168.1.1:/home/public_html
To copy an entire directory and it’s contents you’ll need to add -r as shown below.
scp -r /path/to/images root@192.168.1.1:/home/public_html
Logged in as root (or a user with correct permissions) you can copy the public_html directory from /home/public_html on a server with the IP 192.168.1.1 to another remote host using the following example. Replacing root with your user (if required) and both the source and destination addresses.
scp -r root@192.168.1.1:/home/public_html root@192.168.1.2:/home/public_html
There are few options you can apply to the command that if used correctly can improve its effectiveness. In some cases however, it is preferred to use rysnc instead.
You can utilise basic wildcards with SCP to target multiple files or directories in one command. These wildcards include
When applying a wildcard to a remote host wrap the full source or destination in “ quotes so it is interpreted remotely. In our example below you can see how using a * wildcard can help by copying all backups from June (using a standardised naming convention) in a single command.
scp "root@192.168.1.2:/home/backups/backup-2025-06-*.tar.gz" root@192.168.1.3:/home/backups/