0
我几乎不知道shell脚本或终端命令的任何内容。如何通过shell脚本连接并运行远程服务器上的shell脚本
想要实现:
做一个shell脚本,连接到远程服务器,并连接到该服务器后,该服务器上运行某些命令。
可能吗?
我试过Google搜索,但没有找到东西,我期待。
我几乎不知道shell脚本或终端命令的任何内容。如何通过shell脚本连接并运行远程服务器上的shell脚本
想要实现:
做一个shell脚本,连接到远程服务器,并连接到该服务器后,该服务器上运行某些命令。
可能吗?
我试过Google搜索,但没有找到东西,我期待。
为此,您可以使用SSH(安全壳),你可以参考答案How to use SSH to run a shell script on a remote machine?
/tmp/sh.sh is shell script on remote server.
#!/bin/bash
ssh "[email protected]" 'sh -c "((nohup /tmp/sh.sh))"'
#use following for suppressing the output from remote server script.
ssh "[email protected]" 'sh -c "((nohup /tmp/sh.sh &>/dev/null) &)"'
我有一个疑问这个问题,难道我们不需要任何密码的,因为我连接到其他服务器。在你的代码中表示没有提及密码? – sandeepKumar
@sandeepKumar用私钥设置ssh。 – Barmar