execute commands on remote server using shell script
This question already has an answer here:
Usually it's just
ssh buildserver /path/to/build.sh
You may need to tweak the options though.
Just do ssh <HOST> <COMMAND>
in a single line. If you can already log in using keys you won't have to type a password. Example:
$ ssh localhost 'echo hi'
hi
This <COMMAND>
is run synchronously. That means that ssh
won't finish until <COMMAND>
run on the remote server has finished. See yourself:
$ ssh localhost 'sleep 10'
This command will wait for 10 seconds and you won't be able to type new commands until it's finished.
您可以使用管道(假设您使用* nix OS):
echo "your --command --here" | ssh user@host
链接地址: http://www.djcxy.com/p/97142.html
上一篇: 在远程服务器上以root身份运行本地脚本
下一篇: 使用shell脚本在远程服务器上执行命令