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 your_name@remotehost.edu:sample.txt /some/local/directory

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

$ scp sample.txt your_name@remotehost.edu:/some/remote/directory

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

$ scp -r sample_1 your_name@remotehost.edu:/some/remote/directory/sample_2

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

$ scp your_name@rh1.edu:/some/remote/directory/sample.txt \
your_name@rh2.edu:/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 your_name@remotehost.edu:~

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

$ scp -P 2264 sample.txt your_name@remotehost.edu:/some/remote/directory

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

$ scp your_username@remotehost.edu:/some/remote/directory/\{a1,b1,c1\} .
$ scp your_name@remotehost.edu:~/\{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 your_name@remotehost.edu:~

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 your_name@remotehost.edu:~