Sunday, 15 November 2015

How to copy files remotely over ssh

SCP stands for secure cp (copy), It allows files to be copied to, from, or between different hosts. It uses ssh for data transfer and securely encrypted.

Syntax:
scp [[user@]host1:]file1 ... [[user@]host2:]file2

Examples:

  • Copy the file "foo.txt" from a remote host to the local host
    • $scp username@remotehost.com:foo.txt  /local/linuxinanutshell
  • Copy the file "foo.txt" from the local host to a remote host
    • $scp foo.txt username@remotehost.com:/remote/linuxinanutshell 
  • Copy multiple files using single command
    • $scp file1.txt file2.txt file3.txt username@remotehost.com:/remote/linuxinanutshell

To Increase Speed of scp command:
If you need more speed and still have security, you can use Blowfish or RC4.
scp -c blowfish username@remotehost.com:foo.txt  /local/linuxinanutshell

Or use RC4 which seems to be the fastest
scp -c arcfour username@remotehost.com:foo.txt  /local/linuxinanutshell .

This last one is not very secure, and it may not be used if security is really an issue for you.

You can also limit the bandwidth used by scp command:
Syntax:
scp -l limit username@server:/path/to/file /path/to/folder

Where limit is specified in Kbit/s. So for example, if you want to limit speed at 100 Kbps
Example:
scp -l100 username@remotehost.com:foo.txt  /local/linuxinanutshell 

No comments:

Post a Comment