SCP: Transferring files in Linux

How to send a file with scp in Linux

Suppose you need to send a file big_file to a remote host with the IP 192.168.0.2 and put it in the home directory.

On the remote host you have a user andrei and you know their password

scp big_file andrei@192.168.0.2:/home/andrei

How to download a directory with scp in Linux

To send not just one file but a directory with all its nested files, use the -r option

scp -r directory andrei@192.168.0.2:/home/andrei

How to download a file with scp in Linux

Suppose you need to download a file p_script.py from the Downloads folder on the remote host (192.168.0.2) and put it in your current directory.

On the remote host you have a user andrei and you know their password

scp andrei@192.168.56.2:/home/andrei/Downloads/p_script.py ./

Note the ./ at the end: this is how you specify which directory on your host the file should be saved to.

Article author: Andrei Olegovich