Top 16 SCP Command To Copy Data Remotely In Linux

Top 16 SCP Command To Copy Data Remotely In Linux

We can copy files using SCP command in Linux. It’s used to copy the files from one location to a remote location. It uses the SSH protocol for data transfer and the same mechanism for authentication with the same port number 22. Let’s see, Top 16 SCP command example on Linux.

The SCP syntax for SCP command usage.

scp <options> source_file username@destination_ip:/destination_folder

Example 1: Simply copy from the current location to a remote location.

scp anaconda-ks.cfg root@192.168.185.138:/data

Top 16 SCP Command

Example 2: I have created few files in a directive and I will copy them into the same location.

scp -r files/* root@192.168.185.138:/root/data

linux scp command

Check Out: Learn Top 12 lsof Commands Example For Files In Linux 8

Example 3: I will change file permission and copy them with the same permission on the remote location.

cd files/
chmod 777 *

copying files from one server to another server in linux

scp -pr files/* root@192.168.185.138:/root/data

scp command in linux

Check on the remote folder.

Example 4: Copy only ‘.txt’ files to the remote folder. In a similar way, we can copy any file that ends with a particular extension.

scp -pr files/*.txt root@192.168.185.138:/root/data

how to transfer files from one server to another

Check Out: How To Set Ulimit Users and File Descriptions On Linux Server

Example 5: Send files with verbose using ‘-v’ options.

scp -v files/*.txt root@192.168.185.138:/root/data

server to server file transfer

Example 6: Send multiple files to remote locations.

scp 1.txt 2.txt root@192.168.185.138:/root/data

copy files using scp

Check Out: How To Install WordPress 4.9.x On Redhat/CentOS 7

Example 7: Increase transfer speed using ‘-C’ options and suppose I have created a 1 GB image using fallocate -l +1G file.img. I have to send it to a remote location. This will compress the image and decompress on the remote location.

scp -r -C file.img root@192.168.185.138:/root/data

Example 8: Set limit bandwidth while copying. I have set 600kb/s and I won’t access more than this limit.

scp -l 600 file.img root@192.168.185.138:/root/data

if you want to set the limits in MB or GB, simply use 1GB=1024.

Suppose you want to set the limit 100MB, just simple use 102400 instead of 600.

Check Out: How To Display Timestamp In History Command On Linux

Example 9: Improve performance using ‘-c blowfish’. By default, SCP uses the 3DES cipher to encrypt the data.

scp -c blowfish file.img root@192.168.185.138:/root/data

scp file transfer

Example 10: Copy files from remote to the current location.

scp root@192.168.185.138:/root/data/file.img /root/files/

Check Out: How To Secure Apache Web With Server Hardening In Linux

Example 11: Copy files with different ssh port numbers using the ‘-P‘ option.

scp -P 2020 file.img root@192.168.185.138:/root/data

Example 12: Copy files between one remote location to another remote location.

scp -r root@192.168.185.138:/root/data/file.img root@192.168.185.139:/root/data1

Check Out: How To Assign Elastic IP To Server On Amazon Cloud

Example 13: we can also use the different ssh configuration files except for the default.

scp -rv -F /root/ssh_config file.img root@192.168.185.138:/root/data/

Example 14: Send files in quiet mode with the ‘-q‘ option. It is used to suppress transfer progress, warning, and diagnostic message of ssh.

scp -r -q file.img root@192.168.185.138:/root/data

Check Out: Create Jenkins Production Job For Maven Project On CentOS 7

Example 15: we can send a file with an ‘-i’ option because often we use key-based authentication and we can also use the identity file.

scp -i abc.pem -r file.img root@192.168.185.138:/root/data

Example 16: Use different cipher. By default, it uses the AES-128 cipher.

scp -c 3des-cbc file.img root@192.168.185.138:/root/data

You’re done copy files using scp linux

Share on:

I'm the founder of Curious Viral. I hope this blog will provide you complete information about Linux Technology & I would like to share my technical knowledge with you which I have learned during this period.

Other Posts You May Like...

Leave a comment