A short summary of the format for using scp secure copy to transfer files between a Linux computer and server and server to local computer.
To transfer a file from a remote server:
scp username@192.168.0.200:thefile.txt /local-path/directory
In the above the file shown is within the home directory of the account. Include a directory path as required. The examples below are relative to the home directory and to the file system root respectively:
scp username@192.168.0.200:remote-path/thefile.txt /local-path/directory
scp username@192.168.0.200:/remote-path/thefile.txt /local-path/directory
192.168..200 is the IP address used to reference the remote host. It may also be by domain name unique reference.
Enter the password associated with the account, when prompted.
To recursively transfer a directory from the same server
scp -r username@192.168.0.200:/remote-path/directory /local-path/directory
And the same options going the other way. First to transfer a file to the remote server.
scp -r /path/directory username@192.168.0.200:foobar.txt
And to transfer a directory to the remote server
scp -r username@192.168.0.200:/local-path/directory /remote-path/directory
If the remote server uses a port other than the default, for example 12345 this can be specified with the -P option, example given below:
scp -P 12345 username@192.168.0.200:thefile.txt /path/directory
The table below is a summary of the options available
| Option | Function |
|---|---|
| -1 | Use version 1 of the SCP protocol |
| -2 | Use version 2 of the SCP protocol |
| -C | Use gzip compression |
| -B | Initiate the transfer without the request for a password |
| -i limit | Set a bandwidth limit for the transfer (kb/s) |
| -o ssh_option | The definition of concrete SSH options such as encryption |
| -P port number | The port number to be used to connect to the remote server |
| -p | Preserve the meta information of the files and directories (modification and access timings) |
| -q | Hide the progress bar |
| -r | Recursively copy an entire directory and its sub-directories |
| -S program | Specify the program to be used to encrypt the connection |
SCP can also be used to transfer files on the same computer – although maybe rsync is your preference.


