Beginners Guide: Copy Your Files To Remote Server With scp

When you are moving your website to another server or maybe copying a file to a remote host, there are many ways to do that. One of them is using “scp” or secure copy. scp is used for copying files from a local host to a remote host securely. It uses SSH for data transfer and provides the same authentication and same level of security as SSH.

Copy a file from a remote host to the local host:

scp [email protected]:file.txt /path/local/directory

Copy a file from the local host to a remote host:

scp /path/local/directory  [email protected]:file.txt

Copy a directory from local host to a remote host

scp -r /path/local/directory [email protected]:/path/remote/directory

Copy a directory from remote host to a local host

scp -r [email protected]:/path/remote/directory /path/local/directory

Copy a file from remote host 1 to remote host 2 (copy file between remote hosts)

scp [email protected]:/path/remote/host1/file.txt [email protected]:/path/remote/host2/

Use blowfish cipher to encrypt the data being sent:

scp -c blowfish /path/local/directory  [email protected]:file.txt

Compress the file before sending:

scp -c blowfish -C /path/local/directory  [email protected]:file.txt