Method: generate a public/private key pair on the client, save the private key file on the client, and then upload the public key file to the server (remote host)
1. Generate a public/private key pair on the client [email protected] # ssh-keygen
...
[Email protected] # ls. Ssh/
Id_rsaid_rsa.pub // id_rsa is the private key by default, and id_rsa.pub is the public key.
2. Upload the public key file to the remote host [email protected] # SCP ~ /. Ssh/id_rsa.pub [email protected]:/home/CB/. SSH
3. log on to the remote host and write the client Public Key to the authorized_keys file [email protected] # SSH [email protected]
[Email protected] # cd. Ssh/
[Email protected] # Cat id_rsa.pub> authorized_keys
4. Complete. log on to the remote host without a password on the client [email protected] # SSH [email protected]
[Email protected] # // no password prompt. If you log on directly, the setting is successful.
5. Two-way login without a password
Use the remote host as the client and the original client as the remote host. Repeat steps 1 ~ 4. You can achieve SSH login without a password between the two machines.
6. One client logs on to multiple remote hosts
Repeat Step 2 ~ 3. Upload the client's public key file to multiple remote hosts and write it to the authorized_keys file on the remote host.
Note: Check the authorized_key file permissions, preferably 0644. Once, because the permission for this file is 0664, you cannot remotely log on without a password. Just change it to 0644.
Log on to the remote host using SSH without a password