我有一些服务器,我想在所有服务器上安装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
这个语法对吗?
不起作用。
有什么想法吗?
预先感谢您
ssh和 heredoc
您不能在同一命令行上做 there-doc !
但是您可以在命令行上完全编写遥远的ssh
命令:
Script=$'while read foo ;don echo $HOSTNAME $foondone'
echo "$Script"
请注意使用 double-Quotes !
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