【发布时间】:2014-09-29 15:53:31
【问题描述】:
我正在尝试使用最新的修复包修补一堆 CENT OS 机器。我有以下 bash 脚本,它将 csv 文件作为输入,其中包含这些机器的 IP 地址和密码。
代码工作正常,但是它只适用于第一行它似乎不适用于列表的其余部分,因为我的 output.txt 只有第一行主机的条目。
补丁.sh
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 不是终端。
【问题讨论】:
-
我可能会查看
ssh的-n和-f标志。可能是您的 ssh 进程正在读取指向 while 循环的输入文件的其余部分。我不确定您是否需要-t选项。
标签: linux bash centos shellshock-bash-bug