Thursday, March 05, 2009

Using the SCP command (Linux)

20.3.2. Using the scp Command

The scp command can be used to transfer files between machines over a secure, encrypted connection. It is similar to rcp.

The general syntax to transfer a local file to a remote system is as follows:

scp username@tohostname: 

The  specifies the source including path to the file, such as /var/log/maillog. The  specifies the destination, which can be a new filename such as /tmp/hostname-maillog. For the remote system, if you do not have a preceding /, the path will be relative to the home directory of username, typically /home/username/.

To transfer the local file shadowman to the home directory of your account on penguin.example.net, type the following at a shell prompt (replace username with your username):

 scp shadowman username@penguin.example.net:shadowman  

This will transfer the local file shadowman to /home/username/shadowman on penguin.example.net. Alternately, you can leave off the final shadowman in the scp command.

The general syntax to transfer a remote file to the local system is as follows:

scp username@tohostname: 

The  specifies the source including path, and  specifies the destination including path.

Multiple files can be specified as the source files. For example, to transfer the contents of the directory downloads/ to an existing directory called uploads/ on the remote machine penguin.example.net, type the following at a shell prompt:

 scp downloads/* username@penguin.example.net:uploads

No comments: