我有一些服务器,我想在所有服务器上安装SSL 我编写了以下脚本(我应该从每个服务器运行它):
#!/bin/bash
#something to install SSL on centos
#....
#
注意:我应该像这样运行脚本(因为分配了ssl证书):
./ssl-conf <<EOF
> <CountryNmane>
> <StateName>
> <LocalityName>
> <OrganizationName>
> <OrganizationUnitName>
> <CommonName>
> <EmailAddress>
> <ChallengePassword>
> <CompanyName>
>EOF
现在我的问题: 我想写一个bash来处理我的服务器数量。我写了这样的东西(我应该在我的机器上运行):
#!/bin/bash
while read pass port user ip; do
sshpass -p$pass -o 'StrictHostKeyChecking no' -p $port $user@$ip <<EOF <<SSH
US
something
newyork
test
test1
test2
test3
challengepassword
test4
EOF #End of asking questions
#commands to install SSL
#commands to install SSL
#commands to install SSL
SSH #end of commands running on remote machine
done <<___HERE
mypasswd 22 root 192.168.1.1
mypasswd 22 root 192.168.1.2
mypasswd 22 root 192.168.1.3
___HERE
这种语法是对的吗?
不起作用。
任何想法?
提前谢谢
答案 0 :(得分:1)
你不能在同一命令行上使两个 here-doc !
但是你可以完全在命令行上编写远程ssh
命令:
Script=$'while read foo ;do\n echo $HOSTNAME $foo\ndone'
echo "$Script"
请注意使用双引号!
while read pass port user ip; do
sshpass -p$pass ssh -o 'StrictHostKeyChecking no' -p $port $user@$ip "$Script" <<eoparams
US
something
newyork
test
test1
test2
test3
challengepassword
test4
eoparams
done <<eodests
mypasswd 22 root 192.168.1.1
mypasswd 22 root 192.168.1.2
mypasswd 22 root 192.168.1.3
eodests