* SSH connections between multiple servers
For example, four machines need to communicate with each other without a password.
| ---------- + ------------- |
| Host | IP |
| ---------- + ------------- |
| Server01 | 192.168.0.1 |
| Server02 | 192.168.0.2 |
| Server03 | 192.168.0.3 |
| Server04 | 192.168.0.4 |
| ---------- + ------------- |
** Step 1: generate the respective folders
Server01: # mkdir-P/root/. Ssh; chmod 700/root/. SSH
Server02: # mkdir-P/root/. Ssh; chmod 700/root/. SSH
Server03: # mkdir-P/root/. Ssh; chmod 700/root/. SSH
Server04: # mkdir-P/root/. Ssh; chmod 700/root/. SSH
** Step 2: generate the respective keys
1. Enter the/root/. Ssh/directory and run the following command:
Server01: # ssh-keygen-T RSA
Server02: # ssh-keygen-T RSA
Server03: # ssh-keygen-T RSA
Server04: # ssh-keygen-T RSA
Press enter to generate the corresponding key (Private Key: id_rsa) (Public Key: id_rsa.pub)
Server01: # cp id_rsa.pub authorized_keys
Server02: # cp id_rsa.pub authorized_keys
Server03: # cp id_rsa.pub authorized_keys
Server04: # cp id_rsa.pub authorized_keys
2. Run the following command on the four servers:
Server01: # ssh-keygen-T rsa1-F/etc/ssh/ssh_host_key-n ""
Server01: # ssh-keygen-T rsa1-F/etc/ssh/ssh_host_rsa_key-n ""
Server01: # ssh-keygen-t dsa-F/etc/ssh/ssh_host_dsa_key-n ""
Server01: #/etc/init. d/ssh restart
** Step 3: add the Public Key (id_rsa.pub) of different servers to your authorized_keys file.
(Note: In the following SCP command, you must manually enter the password to log on)
Server01: # SCP 192.168.0.2:/root/. Ssh/id_rsa.pub/root/
Server01: # Cat/root/id_rsa.pub>/root/. Ssh/authorized_keys
Server01: # SCP 192.168.0.3:/root/. Ssh/id_rsa.pub/root/
Server01: # Cat/root/id_rsa.pub>/root/. Ssh/authorized_keys
Server01: # SCP 192.168.0.4:/root/. Ssh/id_rsa.pub/root/
Server01: # Cat/root/id_rsa.pub>/root/. Ssh/authorized_keys
Now/root/. Ssh/authorized_keys on server01 already contains the public key of four servers.
Server01: # SCP/root/. Ssh/authorized_keys SCP 192.168.0.2:/root/. Ssh/authorized_keys
Server01: # SCP/root/. Ssh/authorized_keys SCP 192.168.0.3:/root/. Ssh/authorized_keys
Server01: # SCP/root/. Ssh/authorized_keys SCP 192.168.0.4:/root/. Ssh/authorized_keys
At this point, there should be no password connection between them.
Engoy it!