【发布时间】:2014-01-26 21:58:43
【问题描述】:
我有一些服务器,我想在所有服务器上安装 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
这个语法对吗?
不工作。
有什么想法吗?
提前谢谢你
【问题讨论】:
-
这有点离题,但您确实应该使用基于密钥的身份验证,而不是允许使用密码进行 root 访问。
-
没问题..我使用密码变量检查并工作...问题是如何从远程主机提问
-
你不能在同一行“这里记录”重定向...也就是说,运行
somecommand <<EOF <<SSH不会做任何有用的事情(它可能会忽略 @ 987654325@). -
谢谢///你有什么解决办法吗?