Wednesday, 14 September 2011

Using the SCP Command

Bringing a few of the things I do at work onto the blog, I thought I would leave a tip for GNU/Linux users regarding the use of the SCP command.

SCP (Secure CoPy) can be used to copy files and folders from one host to another. I've mainly used it in this manner:

scp /path/to/file user@remotehost:/target/directory

This will copy the file from the system you are logged in on to the remote host where you want the file to go. I've used it in this way many, many times. In effect you are "pushing" the file to where you want it to go.

Another way that it can be used is to "pull" the file to your local machine. All you need to do is reverse the command:

scp user@remotehost:/path/to/file /local/target/directory

If you're moving directories around then you just add the -r option in order to instruct scp to copy recursively.