Scp command syntax
1. Copy the local file to the remote end
Scp file user @ hostname: remote directory scp 123.txt root@192.168.1.1:/
2. Copy the remote directory to the local
Scp-r user @ hostname: remote directory local directory scp-r root@192.168.1.2:/456.txt ~
3. SCP transfers files without entering a password
In the Linux environment, the scp command is usually used to transfer files between two hosts, and it is usually necessary to enter a password to confirm when using the scp command to obtain the other linux host files through ssh.
However, by establishing a trust relationship, it is possible not to enter a password.
1) execute the following command on one of the hosts to generate the pairing key:
Ssh-keygen-t rsa
Follow the prompts and be careful not to enter passphrase. The prompt message is as follows
Generating public/private rsa key pair.Enter file in which to save the key (/ root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: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:63:61:d2:ce:5f:e8:14:5c:56:2c:7b:08:71:41:a2:cc root@localhost.localdomain
2.) copy the id_rsa.pub file in the .ssh directory to the ~ / .ssh/ directory on another host, and rename it authorized_keys.
Scp .ssh / id_rsa.pub hostname: / root/.ssh/authorized_keys