sandeepKumar
sandeepKumar

Reputation: 811

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.

Upvotes: 0

Views: 2311

Answers (2)

sameerkn
sameerkn

Reputation: 2259

/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 ) & )"'

Upvotes: 1

Kiran Kumar
Kiran Kumar

Reputation: 1051

You can do this using ssh (secure shell), you can refer this question for answers How to use SSH to run a shell script on a remote machine?

Upvotes: 1

Related Questions