Linux 通过ssh运行命令时从远程计算机询问问题
我有一些服务器,我想在所有服务器上安装SSL 我编写了以下脚本(我应该在每个服务器上运行它): 注意:我应该像这样运行脚本(因为分配了ssl证书):Linux 通过ssh运行命令时从远程计算机询问问题,linux,bash,ssl,ssh,Linux,Bash,Ssl,Ssh,我有一些服务器,我想在所有服务器上安装SSL 我编写了以下脚本(我应该在每个服务器上运行它): 注意:我应该像这样运行脚本(因为分配了ssl证书): /ssl-conf > > > > > > > >EOF 现在我的问题是: 我想写一个bash来处理我的服务器数量 #/bin/bash 同时读取通过端口的用户ip;做 sshpass-p$pass-o'StrictHostKeyChecking no'-p$port$user@$ip SSH和heredoc 你不能在同一个命令
/ssl-conf
>
>
>
>
>
>
>
>EOF
现在我的问题是:
我想写一个bash来处理我的服务器数量
#/bin/bash
同时读取通过端口的用户ip;做
sshpass-p$pass-o'StrictHostKeyChecking no'-p$port$user@$ip SSH和heredoc
你不能在同一个命令行上创建两个文档
但您可以完全在命令行上编写远程ssh
命令:
Script=$'while read foo ;do\n echo $HOSTNAME $foo\ndone'
echo "$Script"
注意双引号的使用
读通端口用户ip时;做
sshpass-p$pass ssh-o'StrictHostKeyChecking no'-p$port$user@$ip“$Script”这有点离题,但是你真的应该使用基于密钥的身份验证,而不是使用密码来允许根用户访问。没问题。我使用密码变量进行了检查并工作了…问题是如何从远程主机询问问题。你不必在同一行上“此处记录”重定向…也就是说,运行somecommand谢谢///你有什么办法解决这个问题吗?
./ssl-conf <<EOF
> <CountryNmane>
> <StateName>
> <LocalityName>
> <OrganizationName>
> <OrganizationUnitName>
> <CommonName>
> <EmailAddress>
> <ChallengePassword>
> <CompanyName>
>EOF
#!/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
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