how to use scp command with its examples

The scp command is used to securely transfer files between local and remote servers. it uses the SSH protocol to establish a secure connection and transfer files between the them.

  • About scp: A secure and remote copy program
  • Comes From : openssh-clients-5.3p1
  • Configuration Files:
  • Path: /usr/bin/scp

Examples:

1. To copy the files from source (current directory) to destination

$ scp file.txt myhost.net:/tmp/file.txt

 2. To force scp to use protocol 1

$ scp -1 file.txt myhost.net:/tmp/file.txt

 3. To force scp to use protocol 2

$ scp -1 file.txt myhost.net:/tmp/file.txt

 4. To force scp to use IPv4 addresses only

$ scp -4 file.txt myhost.net:/tmp/file.txt

 5. To force scp to use IPv6 addresses only

$ scp -6 file.txt myhost.net:/tmp/file.txt

 6. To enable the compression while copying

$ scp -C file.txt myhost.net:/tmp/file.txt

 7. To specify the cipher to encrypt the data

$ scp -c cipher file.txt myhost.net:/tmp/file.txt

 8. To specify the file from which the identity (private key) for public key authentication is read

$ scp -i file file.txt myhost.net:/tmp/file.txt

 9. To limit the used bandwidth

$ scp -l 10 file.txt myhost.net:/tmp/file.txt

 10. To to pass options to ssh in the format used in ssh_config

$ scp -o ssh_option file.txt myhost.net:/tmp/file.txt

 11. To specify the port to connect to

$ scp -P 20 file.txt myhost.net:/tmp/file.txt 

12. To preserve modification times, access times, and modes from the original file

$ scp -p file.txt myhost.net:/tmp/file.txt

 13. To disable the progress meter as well as warning and diagnostic messages

$ scp -q file.txt myhost.net:/tmp/file.txt

14. To recursively copy entire directories

$ scp -r /tmp/ myhost.net:/tmp/

 15. To name of program to use for the encrypted connection

$ scp -S program file.txt myhost.net:/tmp/file.txt

 16. To run in verbose mode

$ scp -v file.txt myhost.net:/tmp/file.txt

 

Related Commands: rcp, sftp, ssh, ssh-add, ssh-agent, ssh-keygen, ssh_config, sshd 

One thought on “how to use scp command with its examples

  1. This is a brilliant writing and very pleased to find this site. I couldn’t discover to much different information on your blog. I will surely be back again to look at some other important posts that you have in future.

    linux scp

Leave a Reply

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