SCP and a few useful examples

SCP stands for secure copy. It uses SSL to transfer files across a network, which is especially useful when you want to transfer files securely across the internet.

For this program, I think the best way to learn is by viewing a lot of examples. At least, that was the best and easier way for me to learn theĀ scp program.

This copies foobar from your local host to a remote host:

scp foobar user@remotehost:/path/to/remote/dir

This copies foobar from a remote host to your local host:

scp user@remotehost:foobar /path/to/local/dir

This copies foo and bar from the local host to the remote host:

scp foo bar user@remotehost:/path/to/remote/dir

This copies foo and bar from the remote host to your local host:

scp user@remotehost:/path/to/remote/dir/\{foo,bar\} /path/to/local/dir

This copies the file foobar from remotehost1 to remotehost2:

scp user@remotehost1:/path/to/remote/dir/foobar user@remotehost2:/path/to/remote/dir

This copies the entire directory foo from the local host to the directory bar, on a remote host:

scp -r foo user@remotehost:/path/to/remote/dir/bar

A few switches that you might find useful are below. Remember that all the switches go immediately after theĀ scp command and before and files, paths, or host information.

-r            enable directory recursion
-P XYZ        changes the default port (22) to port XYZ
-C            enable file compression
-c blowfish   use a particular cipher spec, like blowfish
-q            make quite
-v            make verbose
Tagged , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published.

Protected by WP Anti Spam