ssh:自动接受密钥

亚当·马坦(Adam Matan)|

我已经编写了这个小实用程序脚本:

for h in $SERVER_LIST; do ssh $h "uptime"; done

将新服务器添加到时$SERVER_LIST,该脚本将通过以下方式停止:

The authenticity of host 'blah.blah.blah (10.10.10.10)' can't be established.
RSA key fingerprint is a4:d9:a4:d9:a4:d9a4:d9:a4:d9a4:d9a4:d9a4:d9a4:d9a4:d9.
Are you sure you want to continue connecting (yes/no)?

我已经试过yes

for h in $SERVER_LIST; do yes | ssh $h "uptime"; done

没有运气。

有没有一种方法可以ssh自动接受任何新密钥?

莱肯施泰因

使用StrictHostKeyChecking选项,例如:

ssh -oStrictHostKeyChecking=no $h uptime

此选项也可以添加到〜/ .ssh / config中,例如:

Host somehost
    Hostname 10.0.0.1
    StrictHostKeyChecking no

请注意,更改主机密钥后,即使使用此选项,也会收到警告:

$ ssh -oStrictHostKeyChecking=no somehost uptime
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
31:6f:2a:d5:76:c3:1e:74:f7:73:2f:96:16:12:e0:d8.
Please contact your system administrator.
Add correct host key in /home/peter/.ssh/known_hosts to get rid of this message.
Offending RSA key in /home/peter/.ssh/known_hosts:24
  remove with: ssh-keygen -f "/home/peter/.ssh/known_hosts" -R 10.0.0.1
Password authentication is disabled to avoid man-in-the-middle attacks.
Keyboard-interactive authentication is disabled to avoid man-in-the-middle attacks.
ash: uptime: not found

如果不经常重新安装主机,则可以使用该选项降低安全性(但对于经常更改的主机密钥来说更方便)-oUserKnownHostsFile=/dev/null这将丢弃所有接收到的主机密钥,因此它将永远不会生成警告。


有了18.04,就有了一种新的可能性:StrictHostKeyChecking=accept-new来自man 5 ssh_config

If this flag is set to “accept-new” then ssh will automatically
add new host keys to the user known hosts files, but will not
permit connections to hosts with changed host keys.  If this flag
is set to “no” or “off”, ssh will automatically add new host keys
to the user known hosts files and allow connections to hosts with
changed hostkeys to proceed, subject to some restrictions.

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

ssh:自动接受密钥

来自分类Dev

SSH 接受密钥但 SSHFS 不接受

来自分类Dev

有没有办法在PuTTY中自动接受SSH主机密钥(即使更改了密钥)?

来自分类Dev

同步时如何自动接受远程密钥?

来自分类Dev

同步时如何自动接受远程密钥?

来自分类Dev

如何自动接受epel gpg密钥

来自分类Dev

自动获取正确的 SSH 密钥

来自分类Dev

公钥被拒绝,但是ssh密钥被接受

来自分类Dev

无密码的ssh无法接受密钥

来自分类Dev

无密码的ssh无法接受密钥

来自分类Dev

公开密钥被拒绝,但是ssh密钥被接受

来自分类Dev

使我的ssh密钥自动过期

来自分类Dev

su-自动解锁ssh密钥

来自分类Dev

如何禁用 ssh 密钥的自动登录?

来自分类Dev

带有Cron的SSH:不接受RSA密钥

来自分类Dev

接受SSH密钥,但远程主机要求输入密码

来自分类Dev

带有Cron的SSH:不接受RSA密钥

来自分类Dev

检查服务器上接受哪些ssh密钥

来自分类Dev

ssh 不接受通过配置重命名的密钥对

来自分类Dev

使用Ansible自动使用SSH本地密钥进行git部署

来自分类Dev

自动执行密钥序列以恢复卡住的SSH会话

来自分类Dev

如何使ssh-agent按需自动添加密钥?

来自分类Dev

登录后如何自动解锁SSH密钥环

来自分类Dev

如何使用RSA密钥按需自动安装ssh文件系统

来自分类Dev

为什么SSH总是使用服务器接受的第一个密钥?

来自分类Dev

如果已知指纹,如何以编程方式接受SSH主机密钥?

来自分类Dev

ssh,接受同一服务器IP的两个密钥指纹

来自分类Dev

指定服务器接受的允许的客户端SSH密钥类型

来自分类Dev

如何使用自动密码和无密钥将SSH SSH到远程服务器?

Related 相关文章

热门标签

归档