Why is there such a need? Because the server is load balanced and has multiple nodes, and now it is automatically deployed, it can't be deployed once on each node, right? If it is deployed on a server, It is convenient to copy directly and remotely to other servers, but since scp needs to enter password and script is troublesome, it is necessary to establish a mutual trust connection between the two machines. There are This article
Virtual machine: 192.168.0.201 as A 192.168.0.204 as B System: centos 6.5 64 bit Result: A does not need to password SCP file to B
1,use ssh Sign in A，input ssh-keygen -b 4096 -t rsa ，Just press enter all the time. //The display is approximately as follows: Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Created directory '/root/.ssh'. 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: e5:81:a9:33:14:87:28:ae:37:4b:17:f3:e4:4a:4d:e1 root@waiyin1 The key's randomart image is: +--[ RSA 2048]----+ | .... | | . . oo o | | . . ...o o | | . o.E. o . | | . O+ S . | |. + o +o | | o = . | | . . | | | +-----------------+ //After execution, a pair of secret keys will be generated in the directory / root/.ssh /. Where 'id_rsa.pub' is the public key and 'id_rsa' is the private key; 2,hold id_rsa.pub Copy to B Server./ssh Directory, and change the name to authorized_keys， Input: scp -p /root/.ssh/id_rsa.pub email@example.com:/root/.ssh/authorized_keys //Appear: firstname.lastname@example.org's password: ---input B Password for the server scp: /root/.ssh/authorized_keys: No such file or directory，Prompt there is no such directory SSH Get into**B The server**Function: ssh-keygen -b 4096 -t rsa，Then run: scp -p /root/.ssh/id_rsa.pub email@example.com:/root/.ssh/authorized_keys firstname.lastname@example.org's password: ---input B Password for the server id_rsa.pub //Note: the contact has been established. A t this time, you can try scp to copy files to server B without entering password!
To sum up, if you want server A to make A password free remote service to server B, you need to put the public key generated by A to server B, as well as scp to server C.