使用SSH连接远程主机或GitHub,远程主机有多个公钥的情况下,它怎样知道使用哪个公钥来解密

简单的说,是client告诉它的。根据RFC 4252 - The Secure Shell (SSH) Authentication ProtocolTo perform actual authentication, the client MAY then send a signature generated using the private key. The client MAY send the signature directly without first verifying whether the key is acceptable. The signature is sent using the following packet: byte SSH_MSG_USERAUTH_REQUEST string user name string service name string "publickey" boolean TRUE string public key algorithm name string public key to be used for authentication string signature所以服务器端受到请求后,需要检查 public key 是不是在许可范围。还需要检查签名是否正确。


    推荐阅读