Set SSH Trust

Source: Internet
Author: User
Login. Set SSH login without a password. The method is as follows:
Assume that the server a and server B needs to log on to server B with root instead of entering the password on server a. follow these steps:
1) generate a key pair on machine A and execute the following command:
Ssh-keygen-T RSA
Generating public/private RSA key pair.
Enter file in which to save the key (/root/. Ssh/id_rsa):/root/. Ssh/id_rsa
Enter passphrase (empty for no passphrase): Press ENTER
Enter same passphrase again: Press ENTER
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:
F6: 61: A8: 27: 35: Cf: 4C: 6d: 13: 22: 70: Cf: 4C: C8: A0: 23 root @ host1

In this way, id_rsa and id_rsa.pub are generated under the/root/. Ssh/path, where id_rsa is the key and id_rsa.pub is the public key.

2) Copy id_rsa.pub generated on machine A to machine B. Assume that it is copied to the temporary directory of machine B, for example:
SCP/root/. Ssh/id_rsa.pub root@218.242.214.20:/tmp
3) log on to machine B with the root account, go to its home directory, create the authorized_keys file, and set the permissions.
Cd ~ /. SSH
CAT/tmp/id_rsa.pub> authorized_keys
Chmod 400 authorized_keys
Rm-F/tmp/id_rsa.pub

4) test
Go to the root account on machine A and try to log on to machine B. Check if the password is not required.
Note:
The authorized_keys File Permission is very important. If it is set to 777, you still need to provide a password when logging on.
Remember to delete id_rsa.pub in the temporary directory.

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.