简体   繁体   中英

How to connect and run shell script on remote server, via shell script

I hardly know anything about shell script or terminal commands.

Want to achieve:

Make a shell script, that connects to remote server and after connecting to that server, run some commands on that server.

Is it possible?

I have tried googling, but didn't find something, i am looking for.

您可以使用ssh(安全外壳程序)执行此操作,可以参考此问题以获取答案如何使用SSH在远程计算机上运行外壳程序脚本?

/tmp/sh.sh  is shell script on remote server.

#!/bin/bash
ssh "root@server-ip" 'sh -c "( (nohup /tmp/sh.sh) )"'    

#use following for suppressing the output from remote server script.
ssh "root@server-ip" 'sh -c "( (nohup /tmp/sh.sh &>/dev/null ) & )"'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM