Multiple linux servers ssh have no password for each other, and multiple linux servers ssh

Source: Internet
Author: User

Multiple linux servers ssh have no password for each other, and multiple linux servers ssh

Server A: 10.1.11.82

Server B: 10.1.11.210

Objective: to allow server A to access server B without A password

 

Operation logic: to allow server A to access server B without A password, you only needGenerate A key pair on server,Upload the generated public key to the. ssh directory in the related user directory of server B.(If not, create the file manually. Note that the directory permission is 700.) change the public key file name to authorized_keys (note that the permission for this file is 644. the permission of the ssh directory and the authorized_keys file. If the permission does not match, the configuration will be invalid. [Run the ls-la command to view the execution permissions of all directories]

 

The procedure is as follows:

1. Generate A password pair on server:

There are several options in the generation process that allow you to enter the storage directory of the key pair and the private key, just enter.

[Root @ mysqlcluster ~] # Ssh-keygen-t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/. ssh/id_rsa ):
Created directory '/root/. ssh '.
Enter passphrase (empty for no passphrase ):
Enter same passphrase again:
Your identification has been saved in/root/. ssh/id_rsa.
Your public key has been saved in/root/. ssh/id_rsa.pub.
The key fingerprint is:
0e: 4c: ec: e3: 04: 98: b0: 71: 00: 91: 75: 57: ee: 56: a1: 82 root @ mysqlcluster
After performing the preceding step ~ /. Two files, id_rsa and id_rsa.pub, are generated in the ssh directory. id_rsa is the private key and is stored on the local machine. id_rsa.pub is the public key and is uploaded to the remote server.

 

2. Upload the public key to the remote server B that requires login without a password and change it to authorized_keys:
If the. ssh directory does not exist on the remote server B, manually create:
[Root @ www1bak ~] # Mkdir. ssh
[Root @ www1bak ~] # Chmod 755. ssh

Then upload the public key file from server A to remote server B:

[Root @ mysqlcluster ~] # Scp. ssh/id_rsa.pub root@10.1.11.210:/root/. ssh/authorized_keys

The authenticity of host '10. 1.11.210 (10.1.11.210) 'can't be established.
RSA key fingerprint is c9: ef: 0c: 1b: ac: 6c: ef: 84: a4: a7: e5: d1: 20: 58: c8: 73.
Are you sure you want to continue connecting (yes/no )? Yes
Warning: Permanently added '10. 1.11.210 '(RSA) to the list of known hosts. // This step adds Remote Server B to the known_hosts list of the local server (server ).
Root@10.1.11.210's password:
Id_rsa.pub 100% 399 0.4KB/s

 

3. Test

After the public key file is uploaded to the remote server, log on to server B from server A immediately. If the password is not entered, log on to server B, which means the operation is successful. If you want to enter the password, check. whether the ssh directory permission is 700, whether the public key name on the uploaded remote server is changed to authorized_keys, and whether the permission is 644

 

Related Article

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.