Using SCP to transfer files

Using SCP is a great way to transfer files from one machine to another. SCP uses SSH and can move files to/from localhost <-> remotehost or remotehost <-> remotehost.

SCP Syntax: localhost -> remotehost

scp /path/to/source-file user@host:/path/to/destination-file

SCP Syntax: remotehost -> remotehost

scp user@src-host:/path/to/src-file user@dest-host:/path/to/dest-file

SCP Examples

scp file.txt mydomain.com:~/mydir/file.txt
 
scp local_dir/filename myname@host1:remote_dir
 
scp local_dir/* myname@host1:remote_dir
 
scp myname@host1:remote_dir/filename .
 
scp myname@host1:remote_dir/filename  myname@host2:another_dir

Leave a Reply