ssh 不按照 config 执行

ssh 不按照 config 里的配置执行
比如说我在 .ssh/config 里做了如下配置

Host *
   ServerAliveInterval 60

Host hui.lu
    HostName hui.lu
    IdentityFile ~/.ssh/id_rsa_hui_lu
    Port 22

然后当我通过 ssh hui.lu 时,会出现下列提示

Received disconnect from {IP}: 2: Too many authentication failures for cloverstd
Disconnected from {IP}

然后我加上 -v ,发现 ssh 会不停的尝试我的其他 key

OpenSSH_6.9p1, LibreSSL 2.1.8
debug1: Reading configuration data /Users/cloverstd/.ssh/config
debug1: /Users/username/.ssh/config line 1: Applying options for *
debug1: /Users/username/.ssh/config line 4: Applying options for hui.lu
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to hui.lu [IP] port 22.
debug1: Connection established.
debug1: identity file /Users/username/.ssh/id_rsa_hui_lu type 1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/username/.ssh/id_rsa_hui_lu-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.7
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.7 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Authenticating to hui.lu:22 as 'username'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client chacha20-poly1305@openssh.com <implicit> none
debug1: kex: client->server chacha20-poly1305@openssh.com <implicit> none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:5H7q0e8VCdDBAzNLuRjt29QsxHtVxBQzLfv9hLJlenE
debug1: Host 'hui.lu' is known and matches the ECDSA host key.
debug1: Found key in /Users/username/.ssh/known_hosts:61
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/username/.ssh/id_rsa_aliyun
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: /Users/username/.ssh/id_rsa_gench
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: /Users/username/Dropbox/my_config/_ssh/id_rsa_cc
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: /Users/username/.ssh/id_rsa_ejoyinfo
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: /Users/username/.ssh/id_rsa_vultr
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: /Users/username/.ssh/id_rsa_do
Received disconnect from {IP}: 2: Too many authentication failures for cloverstd
Disconnected from {IP}

我的 .ssh 是放在 dropbox 里,并且通过软链接到 $HOME

在 .ssh/config 里添加 IdentitiesOnly yes,可以正常工作了

阅读 4.4k
1 个回答
debug1: identity file /Users/username/.ssh/hui.lu type 1
debug1: key_load_public: No such file or directory

你 ls 看有没有 /Users/username/.ssh/hui.lu 这个文件。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题