Log on to the remote host using SSH without a password

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.