What is Secure Copy and How it is used in Ubuntu GNU/Linux?

| | 2 min read

What is SCP in Ubuntu?

Secure Copy (SCP) allows files to be copied between, to or from different hosts. It uses ssh for data transfer and provides the same authentication and same level of security as ssh. It has some exit status, 0 on success, and if an error occurs it uses >0. I used some SCP options in my Ubuntu terminal.

Here I am sharing some information about SCP options that are used in Ubuntu GNU/Linux - terminal.

How to use SCP in Ubuntu GNU/Linux?

Copy the file "sample.txt" from a remote host to the local host

$ scp [email protected]:sample.txt /some/local/directory

Copy the file "sample.txt" from the local host to a remote host

$ scp sample.txt [email protected]:/some/remote/directory

Copy the directory "sample_1" from the local host to a remote host's directory "sample_2"

$ scp -r sample_1 [email protected]:/some/remote/directory/sample_2

Copy the file "sample.txt" from remote host "rh1.edu" to remote host "rh2.edu"

$ scp [email protected]:/some/remote/directory/sample.txt \
[email protected]:/some/remote/directory/

Copying the files "sample_1.txt" and "sample_2.txt" from the local host to your home directory on the remote host

$ scp sample_1.txt sample_2.txt [email protected]:~

Copy the file "sample.txt" from the local host to a remote host using port 2264

$ scp -P 2264 sample.txt [email protected]:/some/remote/directory

Copy multiple files from the remote host to your current directory on the local host

$ scp [email protected]:/some/remote/directory/\{a1,b1,c1\} .
$ scp [email protected]:~/\{foo.txt,bar.txt\} .
scp Performance

By default, SCP uses the Triple-DES cipher to encrypt the sent data. Using the Blowfish cipher has been shown to increase speed. This can be done by using option -c blowfish in the command line.

$ scp -c blowfish sample_file [email protected]:~

The -C option for compression should also be used to increase speed. The effect of compression significantly increases speed if your connection is very slow. Else it may just be adding an extra burden to the CPU. A simple example of using blowfish and compression:

$ scp -c blowfish -C sample.txt [email protected]:~