SSH Two machines establish trust relationship without password login

Source: Internet
Author: User

Before establishing a trust relationship, look at the encryption and authentication based on public and private keys.

Private key Signing process

消息-->[私钥]-->签名-->[公钥]-->认证私钥数字签名,公钥验证
    1. Alice generates the public and private keys and sends the public key to BoB.
    2. Alice uses her private key to generate a signature, which is encryption.
    3. Alice sends the signed message to Bob.
    4. Bob uses Alice's public key to decrypt and verify the authenticity of the signature.

Public Key Cryptography Process

消息-->[公钥]-->签名后的消息-->私钥-->解密后的消息公钥加密,私钥解密
      1. Bob generates his own public and private key and sends the public key to Alice.
      2. Alice encrypts the information with Bob's public key.
      3. Alice sends the encrypted message to Bob.
      4. BoB decrypts it with his private key and getsthe message sent by Ali CE.
Establish a trust relationship between hosts

Knowing the public and private keys above, let's now build a trust relationship between the two hosts,

ssh-keygen-t RSA #执行完之后会在家目录下的. SSH folder generates Id_rsa, id_rsa.pub two files, and the latter is a public key.

SCP. Ssh/id_rsa.pub user1@192. 168.1.101:/home/user1/

(

Copy the generated id_rsa.pub file to the B server (note that the location of the file is/root/.ssh, if the other user should be/home/user/.ssh, which is the home directory of the current user )

)

On the other machine.

Cd/home/user1

Cat Id_rsa.pub >> Ssh/authorized_keys

chmod ~/.ssh

chmod ~/.ssh/authorized_keys

Whether the test was successful:

SSH [email protected]

If you specify a port plus the-p port number.

Exit the terminal and enter exit.

SSH Two machines establish trust relationship without password login

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.