没有 known_hosts 条目的 ssh 远程命令
ssh remote commands without known_hosts entry
我编写了一个 python 应用程序,它接受用户关于打印机的输入。打印机名称、IP 地址、要使用的端口等详细信息,然后它会发出 ssh 命令来构建该打印队列(CUPS 队列)。
构建打印机的服务器被各种名称引用,例如
- linux服务器 1
- linuxserver1.domain.com
基本上只有主机名和完全限定的域名。
我正在使用 root 帐户执行所有这些任务。
在 linux 服务器上
/root/.ssh/known_hosts 有 'linuxserver1' 的条目,但没有 FQDN 'linuxserver1.domain.com'
的条目
当 python 应用程序发送 ssh 时。 ssh 连接有一个关于 RSA 密钥的提示,就像这样
$ ssh root@linuxserver1.domain.com
The authenticity of host '192.168.20.10 (192.168.20.10)' can't be established.
RSA key fingerprint is 4e:cb:44:bd:c5:1a:c1:1f:b3:43:2e:56:56:f8:e0:af.
Are you sure you want to continue connecting (yes/no)?
大约有 500 台服务器,所以我无法登录每台服务器并通过修改 ssh-config 或在 known_hosts 中添加条目来禁用此检查。
创建服务器阵列
declare SERVERS=('ip_1' 'ip_2'................... 'ip_n);
for i in "${SERVERS[@]}"
do
ssh: ssh-copy-id -i /home/ubuntu/.ssh/id_rsa.pub -oStrictHostKeyChecking=no root@$i
done
我编写了一个 python 应用程序,它接受用户关于打印机的输入。打印机名称、IP 地址、要使用的端口等详细信息,然后它会发出 ssh 命令来构建该打印队列(CUPS 队列)。
构建打印机的服务器被各种名称引用,例如
- linux服务器 1
- linuxserver1.domain.com
基本上只有主机名和完全限定的域名。
我正在使用 root 帐户执行所有这些任务。
在 linux 服务器上 /root/.ssh/known_hosts 有 'linuxserver1' 的条目,但没有 FQDN 'linuxserver1.domain.com'
的条目当 python 应用程序发送 ssh 时。 ssh 连接有一个关于 RSA 密钥的提示,就像这样
$ ssh root@linuxserver1.domain.com
The authenticity of host '192.168.20.10 (192.168.20.10)' can't be established.
RSA key fingerprint is 4e:cb:44:bd:c5:1a:c1:1f:b3:43:2e:56:56:f8:e0:af.
Are you sure you want to continue connecting (yes/no)?
大约有 500 台服务器,所以我无法登录每台服务器并通过修改 ssh-config 或在 known_hosts 中添加条目来禁用此检查。
创建服务器阵列
declare SERVERS=('ip_1' 'ip_2'................... 'ip_n);
for i in "${SERVERS[@]}"
do
ssh: ssh-copy-id -i /home/ubuntu/.ssh/id_rsa.pub -oStrictHostKeyChecking=no root@$i
done