linux - ssh 不按照 config 执行
PHPz
PHPz 2017-04-17 15:29:34
[Linux讨论组]

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,可以正常工作了

PHPz
PHPz

学习是最好的投资!

全部回复(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 这个文件。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号