Fri. Aug 14th, 2020

How to use scp command to transfer data between two Linux servers

2 min read

When we manage the server or VPS, we often upload and download data. For example, when we need to move data from one server to another, we usually download the data from the first server to our computer, and then upload the downloaded data to the remote server through the ftp tool. But this is a waste of time and energy. Why don’t we pack it on the first server and transfer the data directly to another server? The scp command in Linux just happens to be able to transfer data between the two servers.

What is scp

scp is a secure copy, which is used for remote file copy. Data transmission uses ssh, and uses the same authentication method as ssh, providing the same security guarantee. Unlike rcp, scp will ask you for a password or passphrase when authentication is required.



Copy from local to remote

scp /home/ //send the local file to the remote backup directory
scp /home/ //the local file sent to the remote file.

scp -r /home/backup //Copy the local directory backup to the remote directory others

Copy from remote to local
scp /home/ //download the remote file to the local file
scp -r /home/other/ //download the remote directory backup to the local directory other