Bash File Transfer using scp


Syntax

scp transferring file

To transfer a file securely to another machine - type:

scp file1.txt [email protected]:$HOME

This example presents transferring file1.txt from our host to server2's user tom's home directory.

scp transferring multiple files

scp can also be used to transfer multiple files from one server to another. Below is example of transferring all files from my_folder directory with extension .txt to server2. In Below example all files will be transferred to user tom home directory.

scp /my_folder/*.txt [email protected]:$HOME

Downloading file using scp

To download a file from remote server to the local machine - type:

scp [email protected]:$HOME/file.txt /local/machine/path/

This example shows how to download the file named file.txt from user tom's home directory to our local machine's current directory.