IT序号网

unix之仅在配置时使用 ssh key

oomusou 2026年10月07日 编程语言 100 0

关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。












想改进这个问题?将问题更新为 on-topic对于堆栈溢出。

8年前关闭。




Improve this question




我的 .ssh 中有很多 SSH key 目录,每个用于一或两台主机。 key -> server 的映射配置在.ssh/config ,但 ssh 会尝试我要登录的每台服务器上的每个 key 。

对于我没有 key 但想使用导致太多身份验证失败的密码登录的服务器,我必须手动指定 -o PubkeyAuthentication=no .

我可以告诉 ssh 只使用配置的 key 吗?

请您参考如下方法:

试试这个选项来限制身份文件:

IdentitiesOnly

Specifies that ssh(1) should only use the authentication identity files configured in the ssh_config files, even if ssh-agent(1) offers more identities. The argument to this keyword must be ''yes'' or ''no''. This option is intended for situations where ssh-agent offers many different identities. The default is ''no''.



此选项可在使用密码时关闭公钥的使用:

RSAAuthentication

Specifies whether to try RSA authentication. The argument to this keyword must be ''yes'' or ''no''. RSA authentication will only be attempted if the identity file exists, or an authentication agent is running. The default is ''yes''. Note that this option applies to protocol version 1 only.



来源: http://linux.die.net/man/5/ssh_config


评论关闭
IT序号网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!