![为什么我的 ssh 密钥不起作用?](https://linux22.com/image/755336/%E4%B8%BA%E4%BB%80%E4%B9%88%E6%88%91%E7%9A%84%20ssh%20%E5%AF%86%E9%92%A5%E4%B8%8D%E8%B5%B7%E4%BD%9C%E7%94%A8%EF%BC%9F.png)
我在主机 1 上生成了一个 SSH 密钥,并将其放在主机 2 中的 authorized_keys 文件中。当我尝试从主机 1 连接到主机 2 时,它仍然提示我输入密码。以下是-v
连接时添加标志的调试。
OpenSSH_7.4p1, OpenSSL 1.0.2u-fips 20 Dec 2019
debug1: Connecting to 192.168.1.99 [192.168.1.99] port 22.
debug1: Connection established.
debug1: identity file /var/services/homes/imran/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /var/services/homes/imran/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /var/services/homes/imran/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /var/services/homes/imran/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /var/services/homes/imran/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /var/services/homes/imran/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /var/services/homes/imran/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /var/services/homes/imran/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.8p1-hpn13v11
debug1: match: OpenSSH_5.8p1-hpn13v11 pat OpenSSH_5* compat 0x0c000000
debug1: Authenticating to 192.168.1.99:22 as 'root'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: ecdh-sha2-nistp256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: aes128-ctr MAC: [email protected] compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: [email protected] compression: none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: XXXXXXX-OMITTED
debug1: Host '192.168.1.99' is known and matches the ECDSA host key.
debug1: Found key in /var/services/homes/imran/.ssh/known_hosts:1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /var/services/homes/imran/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /var/services/homes/imran/.ssh/id_dsa
debug1: Trying private key: /var/services/homes/imran/.ssh/id_ecdsa
debug1: Trying private key: /var/services/homes/imran/.ssh/id_ed25519
debug1: Next authentication method: password