ssh多机推送公钥不会出现密码认证

wwys 2019-03-26 11:06:18
#!/usr/bin/env bash
while read ip
do
{
ping -c1 -W1 $ip &>/dev/null
if [ $? -eq 0 ];then
/usr/bin/expect <<-EOF
spawn ssh-copy-id root@$ip
expect {
"yes/no" { send "yes\r"; exp_continue }
"password:" { send "123456\r" }
}
expect eof
EOF
fi
}&
done </ip.txt
wait
以上是推送的脚本
下面是执行后的情况
spawn ssh-copy-id root@192.168.95.128
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/
id_rsa.pub"
The authenticity of host '192.168.95.128 (192.168.95.128)' can't be establishe
d.
ECDSA key fingerprint is SHA256:Uk4vyEhCsfA2b7rewb+IcjWA/3YHJyi4zNHobccNtgE.
ECDSA key fingerprint is MD5:e8:82:3b:89:63:bd:c8:c0:a9:9e:d2:43:2c:3f:5b:79.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
执行到这里就停了,按理说应该继续输入密码推送成功的才对很奇怪
...全文
212 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

18,773

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 专题技术讨论区
社区管理员
  • 专题技术讨论区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧