SCP (Secure Copy) is a Linux command that allows secure file transfers between two networked systems. It uses SSH for authentication and encryption, ensuring data is protected during transit. Compared to FTP, SCP is often more efficient for direct server-to-server transfers.
For example, imagine you need to transfer 20 GB of data between two servers. With FTP, you would typically download the data to your local machine before reuploading it—unless using File Exchange Protocol (FXP). In contrast, SCP eliminates this extra step by copying files directly between the two servers.
In this guide, we will explore how to use secure copy protocol for remote transfers and break down its syntax for better understanding. You’ll need to have set up SSH access for your VPS to use SCP, we suggest setting up SSH access with keypairs on your VPS.
SCP (Secure Copy Protocol) is a command-line utility that securely transfers files between local and remote systems using SSH for authentication and encryption. Understanding the basic syntax allows you to transfer files efficiently between machines.
Below is an example command that shows each bit of syntax contained with brackets and its name, use this to get and idea of what you need to form the correct command.
scp [options] [source username@IP]:/[directory and file name] [destination username@IP]:/[destination directory
The following SCP command demonstrates how to transfer a file from one server to another. In this example, a backup file named backup.tar.gz is copied from 192.168.1.1 to 192.168.100.1. This showcases a typical use case where SCP simplifies the transfer of large files between servers.
scp root@192.168.1.1:/home/public_html/backup.tar.gz root@192.168.100.1:/home/public_html/