SCP : Secure file transfer over the network

Requirements:

SCP, for Secure CoPy, is an SSH based software that allows you to copy files between UNIX/Linux machines.

It is included in OpenSSH and the SSH daemon on all mayor Linux & *BSD distributions, listening on port 22 by default.

Usage

SCP works like the well known command “cp”, by adding the required network information (IP, FQDN).

scp /my/file.txt myuser@re.mo.te.ip:~

This will copy the file “file.txt” in the home folder of the user “myuser” to the remote server.

It is also possible to use it the inverse way:

scp myuser@re.mo.te.ip:~/file.txt /my/

This will copy the remote file to the local disk.

Recursion

SCP allows to do recursive copies. Basically this means to copy all its content instead of launch the copy file by file.

Below an example:

scp -r /my myuser@re.mo.te.ip:~

We will now find the directory “my” available in the remote home folder.

As previously seen, this works also the inverse way:

scp -r myuser@re.mo.te.ip:~/my /

If you are interested in more information, feel free to read the manpage of scp. It offers a lot of other functionalities:

man (1) scp