node1:172.16.58.1
node2:172.16.58.3
Node1--> Node2
First generate the secret key in Node1
Execute Command ssh-keygen-p " Ask the save path to enter directly by default, Following prompts to save the private key as/root/.ssh/id_rsa Public key is saved as/root/.ssh/id_rsa.pub |
[[email protected] ~]# ssh-keygen-p ' Generating public/private RSA key pair. Enter file in which to save the key (/ROOT/.SSH/ID_RSA): 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: dc:62:ba:81:ac:dd:d9:93:fa:b4:9b:21:8d:e7:98:8c [email protected] The key ' s Randomart image is: +--[RSA 2048]----+ | | | | | | | . . | | S. | | . . = . | | o = =. | | O +%o+ | | . E Oobo | +-----------------+ |
Pass the secret key to the Node2 host.
Ssh-copy-id-i. ssh/id_rsa.pub [Email protected] |
[Email protected] ~]# ssh-copy-id-i Ssh/[email protected] The authenticity of host ' 172.16.58.3 (172.16.58.3) ' Can ' tbe established. RSA key fingerprint isdb:f8:11:fa:7d:30:95:44:1b:eb:ea:89:ee:fa:a1:27. Is you sure want to continue connecting (yes/no)? Yes warning:permanently added ' 172.16.58.3 ' (RSA) to the listof known hosts. [email protected] ' s password: Now try logging to the machine, with "ssh" [email protected] ' ", and check in: . Ssh/authorized_keys To make sure we haven ' t added extra keys thatyou weren ' t expecting. |
Test for successful password-free login, no prompt to enter password
SSH 172.16.58.3 ' date ';d ate |
[Email protected] ~]# ssh 172.16.58.3 ' date ';d ate Wed Dec 16:51:41 CST 2014 Wed Dec 16:52:42 CST 2014 |
No password-based SSH communication between hosts