Linux scp command using tutorial

  

scp is the abbreviation of secure copy, it is a secure remote file copy command based on ssh login under Linux system. We can use the scp command to copy files and directories between two Linux hosts.

Copy from local host to remote host Common format: scp [optional parameter] Local file or directory remote user name @remote address: remote file or directory

Copy file: scp -P 12333 /home/www/web.tar.gz [email protected]:/home/backup Copy the web.tar.gz file in the /home/www directory to the /home/backup directory of 10.10.0.211, 10.10 The ssh port of .0.211 is 12333.

Copy directory: scp -P 12333 -r /home/www/[email protected]:/home/abc.com/Copy the /home/www/directory and its files to 10.10 In the /home/abc.com/directory of .0.211 (copying the entire directory), the ssh port of 10.10.0.211 is 12333.

Copy from remote host to local host common format; scp [optional parameter] remote username @remote address: remote file or directory local file or directory

is similar to local copy to remote It is enough to swap the local address and the remote address.

scp -P 12333 [email protected]:/home/backup/web.tar.gz /home/test1

scp -P 12333 -r [email protected]:/home /abc.com//home/test2/

Complete Command Format: scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [[user@]host1:]file1 [...] [[user@]host2:]file2

Parameter Description: [-1246BCpqrv]-1 Forces scp The command uses the protocol ssh1. -2 Forces the scp command to use the protocol ssh2. -4 Forces the scp command to use only IPv4 addressing. The -6 mandatory scp command uses only IPv6 addressing. -B uses batch mode (transfer password or phrase is not asked during transmission). -C allows compression (passing the -C flag to ssh to turn on compression). -p keeps the modification time, access time and access rights of the original file. -q does not display the transfer progress bar. -r Recursively copies the entire directory. -v detailed mode display output. Scp and ssh(1) will show debugging information for the entire process. This information is used to debug connections, verification and configuration issues.

[-c cipher] encrypts data transmissions with cipher. This option is passed directly to ssh.

[-F ssh_config] specifies an alternate ssh configuration file, which is passed directly to ssh.

[-i identity_file] reads the key file used for the transfer from the specified file. This parameter is passed directly to ssh.

[-l limit] limits the bandwidth that users can use, in Kbit/s.

[-o ssh_option] specifies the format used in the delivery.

[-P port] specifies the port number used by the remote host ssh.

[-S program] specifies the program to use for encrypted transmission. This program must be able to understand the options of ssh(1).

Copyright © Windows knowledge All Rights Reserved