Skip to content


Copy a file to remote server with scp

This assumes that ssh runs on the remote machine.

To copy a file to a remote machine use the following command:

CODE:
  1. scp /path/to/file user@remotehost:/path/to/destination

To set the access port use the -P switch:

CODE:
  1. scp -P 1234 /path/to/file user@remotehost:/path/to/destination

If you need to copy from the remote host to the local host, reverse the above command

CODE:
  1. scp user@remotehost:/path/to/file /path/to/destination

if you need to copy an entire directory full of files to a remote location, use the -r argument

CODE:
  1. scp -r /path/to/directory/ user@remotehost:/path/to/destination/

If you are transferring logfiles or other highly compressible files, you might benefit from the -C argument. This turns on compression, which, while it will increase the CPU usage during the copy, should also increase the speed in which the file transfers.

Use the -l argument to limit how much bandwidth is used. Follow -l with the bandwidth you want to use in kilobits per second. So, to transfer a file and limit it to 256 Kbps use the following command

CODE:
  1. scp -l 256 /path/to/file user@remotehost:/path/to/destination

Posted in Uncategorized.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.