How to configure ssh password-free login in linux

Source: Internet
Author: User
There are two virtual machines with centos installed on two laptops. you need to set up ssh password-free login. The steps are as follows:

I have two virtual machines with centos installed on my laptop. one IP address is 172.16.1.10 (slave) and the other IP address is 172.16.1.9 (master ).

Use the root user vi/etc/hosts on slave to add the 172.16.1.9 master.

1. run the following command on slave:

Copy codeThe code is as follows:
Ssh-keygen-t rsa or ssh-keygen-t rsa-p''

-P indicates the password.-P ''indicates that the password is empty, or you do not need the-P parameter. in this case, you have to press enter three times and press enter once with-P.
It is in ~ The. ssh directory is generated under the Directory, and id_rsa and id_rsa.pub under. ssh.


2. execute the scp Remote Copy command on the slave:

Copy codeThe code is as follows:
Scp ~ /. Ssh/id_rsa.pub
Because no password-free login is set at this time, you need to enter the password for remote copy.

(Scp command format:

Copy codeThe code is as follows:
Scp local_file
 
3. run the following command on the master:

Copy codeThe code is as follows:
Cat ~ /Id_rsa.pub> ~ /. Ssh/authorized_keys

Append the public KEY to the authorization KEY.
 

4. run the following command:

Copy codeThe code is as follows:
Chmod 600 ~ /. Ssh/authorized_keys

The authorized_keys permission is 600.

Now the server load balancer can use ssh master.
Summary: The logon host has a private key, and the logged-on host must have a public key. This public/private key pair is generally generated on the host machine of the private key. The above is a public/private key pair using the rsa algorithm. of course, you can also use dsa (the corresponding file is id_dsa, id_dsa.pub)

If you want A and B to log on to each other without A password, configure the same method as above.

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.