When we are configuring multiple computations so that they can be used with each other without password login-ssh, before it is a single configuration, now add B on one a, and then add a on another B, so that the content in Authorized_keys is the same, but not exactly the same, such as the order of addition. If more than 2 units, this configuration is quite complex, and error-prone. Later, a simple configuration was seen on the web, and all the machines needed to be configured again.
1. Install SSH. sudo apt-get install SSH. when the installation is complete, a hidden folder is generated in the ~ directory (the current user home directory, which is/home/xuhui here). SSH (Ls-a can view hidden files). If you do not have this file, you can create a new one (mkdir. ssh).
2. Enter the. SSH directory below, execute on each machine: ssh-keygen-t RSA followed by a return, generating a key;
3. After completing the second step, two files are generated:
Id-rsa #私钥
Id-rsa.pub #公钥
4. In the directory of the first machine. Execute commands under SSH, cat id-rsa.pub >> Authorized_keys; After that, theauthorized_keys file appears under SSH.
5. Then copy the Authorized_keys file under the. SSH directory of the first machine to the. SSH directory of the second computer, such as: SCP Authorized_keys [Email protected]:~/.ssh/
6. Next to the. SSH directory of the second machine, you will find the file-authorized_keys just transferred, and then execute the command to add the second computer's public key, such as: Cat Id-rsa.pub >> Authorized_keys.
7. Transfer the newly generated authorized_keys of the second computer to the third computer and add the public key-id-rsa.pub of the third computer to the Authorized_keys passed from the second computer.
8. And so on, until the last computer in the cluster.
9. After the last computer in the cluster finishes adding, the generated Authorized_keys file contains the public key of all the computers in the cluster and can be added directly to the file-authorized_keys if there are additional machines in the cluster. Finally, the last generated Authorized_keys is copied to the. SSH directory of each computer in the cluster, overwriting the previous authorized_keys.
10. After sinking the nineth step, you can log on to any computer in the cluster, password-free SSH login to other calculations.
An easy way to configure SSH password-free login between multiple computers in a cluster