检查是否是SSH提示输入密码 [英] check is SSH prompt for password or not
本文介绍了检查是否是SSH提示输入密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有数百个主机的列表.我想在一个循环中使用ssh运行命令,如果我的ssh密钥设置正确,那么如果遇到密码挑战,我想跳到下一个主机,然后执行命令
Hi I have a list of few hundred hosts. I want to run a command using ssh in a loop, if my ssh keys are set properly, then I execute a command if I get challenge for password I want to skip to the next host
所以可以说我有hosta和hostb以及hostc.我可以对hosta& hostc,但是hostb向我挑战密码.有没有一种方法可以检查主机是否会向我询问密码?所以我的逻辑是
So lets say I have hosta and hostb and hostc. I can do a ssh to hosta & hostc , but hostb is challenging me for password. Is there a way to check if a hosts will challenge me for password or not? So my logic would be
if I get challenge from $host; then
skip host
else
ssh $host 'command'
fi
我希望这是有道理的.预先谢谢你
I hope this makes sense. Thanking you in advance
推荐答案
for host in host1 host2 host3; do
ssh -o PasswordAuthentication=no $host command
done
要使其平行添加&
:
for host in host1 host2 host3; do
ssh -o PasswordAuthentication=no $host command &
done
这篇关于检查是否是SSH提示输入密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文