SCP is a command from SSH toolset used to copy files from one host to another. Often it is used to copy files from your local PC to the server on which you have SSH access, or reversely from the server to your local PC.
How to write a command:
scp /path/to/file.txt email@example.com:/path/on/server/to/
file.txt from your pc to server on IP
22.214.171.124, by accessing ssh for the root user. You should know the password of the root user or have your public key installed to
/root/.ssh/authorized_keys on server.
Reverse operation - copy from server to local pc:
scp firstname.lastname@example.org:/path/on/server/to/file.txt /path/on/local/machine/
How to write SCP command to copy the folder📂
To copy folder between hosts:
scp -r /path/to/folder email@example.com:/path/on/server/
folder and nested files to
⚠ If your folder has a lot of small files inside we strongly recommend not use SCP, but use
tar + sshcommand to speed the process up:
tar -czf - /path/to/folder | ssh [email protected] tar -xzf - -C /path/on/server/
It is the faster equivalent for the above command. Why: because how long does a server transfer take depends not on size, but on files count. Here we just tar files with simple GZIP compression to one stream and pass this stream over SSH stdio.