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, the Authorized_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.
9. After the last computer finishes adding, the generated Authorized_keys file contains the public key of all computers and can be added directly to the file-authorized_keys if there are additional machines in the future. Finally, copy the last generated Authorized_keys to the. SSH directory of each computer, overwriting the previous authorized_keys.
10. After sinking the nineth step, you can login to other computations on any computer, password-free ssh.
Notes note the following two files (clips) have permission settings to make sure that they are correct.
chmod ~/.ssh
chmod ~/.ssh/authorized_keys
Reference: https://www.cnblogs.com/hrx-star/p/5795765.html
Configure SSH-free login between multiple hosts in Linux