15 Practical examples of scp command

SCP is the most useful command for Linux system administrator, almost every day we use this command. In this article, we have explain most of the scenarios with scp command example.

It is used to copy a file/directory from a system to another remote system.

SCP uses the SSH protocol to transfer files. It also uses SSH authentication to communicate with a remote system or server.

Suggested Reading: Linux command Help and Examples

Here, In this article, we will discuss SCP uses through best SCP command example:

Copy a file to remote system

To copy a file into the remote server, you can use source and destination path.

$ scp  linuxconcept.pdf  satish@linuxconcept.com:.

The above scp command example will copy the linuxconcept.pdf file into satish’s home directory at “linuxconcept.com” system.

Copy multiple files to remote system

You can transfer multiple files using SCP tool; a space like below example can specify multiple files.

$ scp  test.txt  test1.txt  linuxconcept@linuxconcept.com:/tmp/

You can copy multiple files from a remote host to the current directory, as shown below:

$ scp linuxconcept@linuxconcept.com:/home/linuxconcept/{test.txt, test1.txt}  .

Run SCP command in Verbose mode

There is an option -v to use to get detailed information while copying the file between host. The option -v is used to execute SCP in verbose mode so that it will print debug information into the screen.

$ scp  -v  linuxconcept.pdf  satish@linuxconcept.com:.

Copy file with modification times, access times, and modes from original files

You can copy a file with modification time, access time and modes from original files, and the option -p will help you to do this, as shown below:

$ scpp command.pdf linuxconcept@inuxconcept.com:.

Use “-C” option to transfer files faster

You transfer your files very fast using the -C option with SCP tool. The -C parameter will compress the files. The important thing is compression only happens on a network, and when it arrived on destination server it will return into the original size.

You can use the -C option, as shown below:

$ scpC command.pdf linuxconcept@linuxconcept.com:.

Use cipher to encrypt files

You can encrypt files while transferring using scp command. By default, scp use AES-128 to encrypt but you can change encryption algorithm using the -c option, as shown below:

$ scpc 3des command.pdf linuxconcept@linuxconcept.com:.

The above command changes the SCP encryption algorithm from AES-128 to 3DES.

Use bandwidth with SCP to control Network bandwidth

There is one option -l using with scp command to control file transfer bandwidth. This is most useful when you want to transfer a huge file, but you don’t want the all bandwidth consumed by the SCP process.

$ scpl 400 all_command.pdf linuxconcept@linuxconcept.com:.

The value 400 with -l option of SCP command is limiting the bandwidth for scp process is 50KB/sec, the 400 is in Kbit so if you convert it into Kbyte it will become 50 KB.

400/8 = 50.

Use specific port for remote system with SCP command

To use a specific port with SCP command, you can use the -P option, as shown below:

$ scp -P 44444 linuxconcept.pdf satish@linuxconcept.com:.
satish@linuxconcept.coms password:
linuxconcept.pdf 100% 4567KB 245.3KB/s 00:21

Run SCP command recursively

You can use the -r option with scp to execute it in recursively, as shown below:

$ scpr  commands  linuxconcept@linuxconcept.com:.

The SCP use in recursively mode to transfer the directories with all files and directories inside of it.

Disable Progress meter and warning/diagnostic messages

In the case when you don’t want to see progress meter and warning messages while using SCP utility, use -q option, as shown below:

$ scpq command.pdf  linuxconcept@linuxconcept.com:.

Use proxy with SCP command

Generally, we are using proxy servers in the office environment. SCP is not proxy configured so when we using proxy environment need to tell SCP to communicate with proxy.

Here, the proxy address is and the proxy port is 8080. The proxy can also use the authentication, so first, you need to create “~/.ssh/config” file, then put below command inside it.

ProxyCommand  /usr/bin/corkscrew 8080 %h %p ~/.ssh/proxyauth

Where the file ~/.ssh/proxyauth contain username and password in below format:


The above command will only work if corkscrew installed in your system, to install it using below command:

$ apt-get install corkscrew
# yum install corkscrew

Use different ssh_config file for SCP 

If you are always switching proxy and public network, it better to configure a different ssh_config file with all required proxy configuration which can use whenever it needed.

You can use a different ssh configuration file with SCP command, as shown below:

$ scp  -F  /home/linuxconcept/proxy_ssh_config  linuxconcept.pdf
linuxconcept@linuxconcept.coms password:
linuxconcept.pdf 100%  3578KB   234.3KB/s   00:13

By default ssh_config file per user will be in ~/.ssh/config. Create a specific ssh_config file with proxy compatible, and use it whenever you are in proxy network.

Whenever you use in your proxy network use -F option and when you are on a public network, you can skip the -F parameter.

SCP authenticate with Key file

You can use key-based (passwordlessauthentication; you need to use identity file which contains the private key. This identity file can use with the SCP command directly, as shown below:

$ scp  -vCqI private_key.pem linuxconcept.pdf  linuxconcept@linuxconcept.com:/tmp/linuxconcept.pdf


Submit a Comment

Your email address will not be published. Required fields are marked *

five × four =

Related Articles