sshpass
为什么在循环中使用时第一个sshpass
执行命令,而下一个却不执行?
for element in "${a[@]}"
do {
echo "$element"
sshpass -p "omg" ssh root@$element 'ls'
}
done
答案1
我找到了解决办法:
for element in "${a[@]}" do
echo "$element"
export SSHPASS='omg'
sshpass -e ssh -o StrictHostKeyChecking=no root@$element 'ls'
unset SSHPASS
done