我有一个
shell脚本,通过SSH连接到同一个主机(我的服务器),并在整个脚本中运行各种命令.例如:
ssh -o ConnectTimeout=3 -o ConnectionAttempts=3 user@my-server "foocommand here"
mkdir -p /path/here
touch service.conf
...
ssh -o ConnectTimeout=3 -o ConnectionAttempts=3 user@my-server "barcommand here"
mkdir -p /other/path/here
touch /other/path/here/service.conf
...
ssh -o ConnectTimeout=3 -o ConnectionAttempts=3 user@my-server "darcommand here"
等等.问题是每个SSH连接都打开,握手需要一些时间,因为服务器my-server在地理位置上远离正在运行的脚本.
有没有办法加快此过程并阻止为每个必需的命令打开新的SSH连接?像http这样的东西能保持活着吗?