SCP or Secure Copy is a useful program for sending files between two or more computers over a secure shell (SSH) connection. In this post, I’ll show you how to use SCP to send files from your local computer to a remote, copy files from a remote computer to your local or copy files between two servers.
An SCP command has the following basic structure:
scp [OPTION] [user@src_host:] file1 [user@dest_host"] file2
Where OPTION refers to the optional flags you can pass to
scp such as the following:
-Premote host SSH port
-ppreserve file modification and access times
-rcopy directories recursively
The colon (:) that comes after the host IP address or domain name is important.
Sending a file from the local computer to a remote computer
scp file.txt email@example.com:/path/to/remote/dir
Copy a file from the remote computer to the local computer
scp firstname.lastname@example.org:/path/to/file.txt /local/directory
Copy files between TWO remote computers
scp email@example.com:/path/to/file.txt firstname.lastname@example.org:/path/to/file/location