In recent times, the SCP has often been used to convey something, and it is not good enough to know what to do with this command.
The SCP command is similar to the CP command, except that the CP command is used on the same machine, and the SCP is a command to replicate the transmitted data on both machines. The SCP essentially corresponds to the CP command that transmits data using the SSH protocol.
Examples of usage:
1. copy files from remote server to Local:
scp-p888 [Email protected]:/data/ha97.zip/home/
2. Copy the directory of the remote server to Local:
scp-vrp-p888 [Email protected]:/data/ha97//home/
3. Copy the local files to the remote server:
scp-p888/home/ha97.zip [Email protected]:/data/
4. Copy the local directory to the remote server:
scp-vrp-p888/home/[Email protected]:/data/
SCP command syntax
SCP [ -1245BCPQRV] [-C cipher] [F ssh_config] [-I identity_file] [-l limit] [-O ssh_option] [-P port] [-S program] [[Email Protected]]host1:] file1 [...] [[Email Protected]]host2:]file2
SCP Command Description
SCP copies files between hosts. He uses SSH (1) as a data transfer. And with the same authentication and security. SCP will request input password in authentication All files may require a special description of the server and the user to indicate that the file will be copied to/from a server. File replication between two remotely-enabled servers is allowed.
SCP command Options
-1 Mandatory SCP with protocol 1
-2 Mandatory SCP with protocol 2
-4 mandatory SCP with IPV4 URL
-6 mandatory SCP with IPV6 URL
-B Select Batch mode (prevents password entry)
-C allows compression. Callout-C to SSH (1) to allow compression
-C cipher
Select cipher to encrypt the data transfer. This option is passed directly to SSH (1)
-F Ssh_config
Set up a variable user configuration to SSH. This option is passed directly to SSH (1)
-I. Identity_file
Select the file to read the private password by RSA authentication. This option can be passed directly to SSH (1)
-L Limit
Limit transmission bandwidth, which is speed with kbit/s speed
-O ssh_option
You can upload the configuration format from the Ssh_config to SSH. This mode is useful for stating that there are no independent SCP file break characters. About the options are as follows. And their values please refer to Ssh_config (5)
-P Port
Specifies the connection to the remote connection port. Note that this option needs to be written in uppercase mode. Because-P has retained the number of times and patterns earlier
-S Program
Specifies an encryption program. This program must be readable by all SSH (1) options.
-p Specifies the number of changes, the number of connections, and the mode for the original file
-Q Turn off the progress parameters
-R recursively copy the entire folder
-S Program
Specifies an encryption program. This program must be readable by all SSH (1) options.
-V redundancy mode. Let SCP and SSH (1) Print their troubleshooting information, which is useful in troubleshooting connections, authentication, and configuration.
SCP Command Diagnostics
When the SCP returns 0 success, the return value is greater than 0 when unsuccessful
SCP command does not require the use of user passwords
After you establish a secure trust relationship between the two users of the two machines, you do not need to enter the user's password when implementing the SCP command.
1. On machine A root user executes the Ssh-keygen command to generate a certificate that establishes a secure trust relationship.
[Email protected] root]# Ssh-keygen-b 1024-t RSA
Generating public/private RSA key pair.
Enter file in which to save the key (/ROOT/.SSH/ID_RSA): <– Direct Input Enter
Enter passphrase (empty for no passphrase): <– Enter directly
Enter same passphrase again: <– Direct Input Enter
Your identification has been saved In/root/.ssh/id_rsa.
Your public key has been saved in/root/.ssh/id_rsa.pub.
The key fingerprint is: ...
Note: When the program prompts for passphrase, enter the carriage return directly, indicating that no certificate password is required.
The above command generates the private key certificate Id_rsa and the public key certificate id_rsa.pub, which is stored in the. SSH subdirectory of the user directory.
2. Copy the public key certificate id_rsa.pub to the. SSH subdirectory of machine B's root directory, and replace the file name with Authorized_keys.
[Email protected] root]# scp-p ssh/id_rsa.pub [email protected] Machine B Ip:/root/.ssh/authorized_keys
[email protected] ' s password: <– Enter the root user password for machine b
When executing the above command, the root user of the two machines has not established a secure trust relationship, so you will also need to enter the root user password for machine B.
After the above 2 steps, a secure trust relationship is established between root of machine A and root of machine B. Here we look at the effect:
[Email protected] root]# scp-p test [email protected] Machine B IP Address:/root
It worked! You really don't need to enter your password anymore.
This article is from the "Share with June" blog, please be sure to keep this source http://kevin92.blog.51cto.com/6928681/1600632
An explanation of SCP command usage