我正在尝试使用最新的修订包修补一堆CENT OS计算机。我有下面的bash脚本,它将csv文件作为输入,这些文件具有这些机器的ip地址和密码。
该代码运行良好,但是,它仅适用于第一行,而对于其余列表似乎不起作用,因为我的output.txt仅具有适用于第一行host的条目。
补丁
INPUT=hosts_test.cvs
OLDIFS=$IFS
IFS=,
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read privateip password
do
sshpass -p$password ssh -t -o "StrictHostKeyChecking no" user123@$privateip "
hostname
hostname -I --all-ip-addresses
sudo yum -y update bash
env x='() { :;}; echo vulnerable' bash -c \"echo If you see the word vulnerable above, then you are vulnerable to shellshock\"
echo ""
exit
" >> output.txt
done < $INPUT
IFS=$OLDIFS
hosts_test.cvs
10.xxx.xx.219,abcd~qY1
10.xxx.xx.226,l4~abcdefg
10.xxx.xx.221,l4@abcdefgh
终端输出
因为stdin不是终端,所以不会分配伪终端。
在sshpass命令的末尾添加</dev/null
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句