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.
scp file.txt email@example.com:/path/to/remote/dir
scp firstname.lastname@example.org:/path/to/file.txt /local/directory
scp email@example.com:/path/to/file.txt firstname.lastname@example.org:/path/to/file/location
scp -i mykey.pem somefile.txt email@example.com:/