File transfer with scp in Linux

How to send a file with scp in Linux

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

On the remote host you have the user andrei and you know his password

scp big_file andrei@192.168.0.2:/home/andrei

To send not one file but a directory with all the 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 the file p_script.py from the Downloads folder from the remote host (192.168.0.2) and put it in your current directory.

On the remote host you have the user andrei and you know his password

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

Note the ./ at the end - it tells the command which directory on your host to save the file to.

Article author: Andrei Olegovich