SCP,which stands for 'secure copy command' is a utility tool used by Linux systems to copy files and directories between hosts in the network. SSH is used to transfer files and authenticate users. As you require credentials to access a remote server using ssh, in a similar way you need to know the credentials of the remote hosts while running SCP commands.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related Linux SSH queries.

In this context, we shall look into some useful SCP commands.

1. How to Copy file from one server to another ?

To copy a single file from one server to another in the network, use the following command:

$ scp file.txt root@

Where , file.txt is the file name, root is the remote host's username , is the remote server's address and /root/Linuxapt is remote directory.

2. How to Find the copy status ?

Scp command along with option -v can be used to show the copy status:

$ scp -v file root@

3. How to Preserve file attributes

Once we copy files/folders to the destination server, the copied files will take the destination server's latest timestamp. Use SCP command with option -rvp to preserve attributes of file such as permission, timestamp:

$ scp -rvp file root@

4. How to Hide SCP output ?

Scp outputs including warnings, errors, and progress meter can be suppressed by using SCP with option -q as:

$ scp -q file root@

5. How to Transfer file using a random port ?

Scp command with option -P can be used to transfer the files using a different port other than the default 22 port. Specify the SSH port after -P command and run SCP command as:

$ scp -P 1022 file root@

Where 1022 is the custom SSH port of the remote host.

6. How to Use an authentication key instead of password ?

If the remote host is configured with ssh key authentication instead of a password then you need to use the ssh key file to access the remote host. To transfer the files/directories specify the ssh key file and run SCP command with option -i as:

$ scp -i private.pem file root@

Where private.pem is the key file for remote server authentication.

7. How to Limit bandwidth ?

The bandwidth of file transfer can be limited using SCP command with option -l. In this example, I have limited bandwidth to 200kbit/s:

$ scp -l 200 centos-iso.tar.gz root@

8. How to Copy file from a remote host ?

Files/Folders can be copied to localhost from a remote server using SCP command as:

$ scp root@ 

Where root is the username of the remote machine, /root/Linuxapt is the remote directory and . is the current directory in the local server.

Scp command with option -r can be used to copy directories from the remote host as:

$ scp -r root@ 

Where Linuxapt is the name of the remote directory.

9. How to Transfer files based in IPV4 only ?

Only IPV4 address can be used to contact remote hosts to transfer files/directories using SCP command with option -4 as:

$ scp -4 file root@

If you need to use the IPV6 address only, run the SCP command as:

$ scp -6 file root@

10. How to Disable strict file checking ?

Strict file checking while copying files/folders from remote host to the local server can be disabled by using SCP command with option -T as:

$ scp -T root@ .

Where is the remote host and documents.tar.gz is the filename.

11. How to Compress files/folders for faster transfer ?

Files/Directories can be compressed using SCP command with option -C while copying to a remote server. The compression of the file takes place at the network level and at the destination, the file size will be the same as the source:

$ scp -C centos.iso.tar.gz root@

12. How to Copy Directory instead of files ?

You can copy directory instead of individual files separately using SCP command with option -r as:

$ scp -r example root@

Where example is the name of the folder.

13. How to Copy multiple files ?

Multiple files can be copied to a remote server using SCP command by specifying the name of the files as:

$ scp file file1 file2 file3 file4 root@

Where file file1 file2 file3 and file4 is the filename.

14. How to Use another cipher to encrypt files/folders ?

During the file transfer, Linux uses AES-128 algorithm to encrypt the files. Other encryption algorithms can be used using SCP command with option -c. Here, we used 3des-cbc cipher to encrypt the files:

$ scp -c 3des-cbs file root@

15. How to perform Remote to remote host copy ?

Files/Directories can be copied from one remote host(example host1) to another remote host (host2) from localhost (host) as:

$ scp root@ root@


  • -> Remote host (host1)
  • -> Remote host (host2)

[Need assistance in installation Software Packages in any Linux Distribution ? We can help you. ]


More Linux Tutorials

We create Linux HowTos and Tutorials for Sys Admins. Visit us on IbmiMedia.com

Also for Tech related tips, Visit forum.outsourcepath.com or General Technical tips on www.outsourcepath.com