Before establishing a trust relationship, look at the encryption and authentication based on public and private keys.
Private key Signing process
消息-->[私钥]-->签名-->[公钥]-->认证私钥数字签名,公钥验证
- Alice generates the public and private keys and sends the public key to BoB.
- Alice uses her private key to generate a signature, which is encryption.
- Alice sends the signed message to Bob.
- Bob uses Alice's public key to decrypt and verify the authenticity of the signature.
Public Key Cryptography Process
消息-->[公钥]-->签名后的消息-->私钥-->解密后的消息公钥加密,私钥解密
- Bob generates his own public and private key and sends the public key to Alice.
- Alice encrypts the information with Bob's public key.
- Alice sends the encrypted message to Bob.
- 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