0

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.

0

2 Answers 2

1

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?

Sign up to request clarification or add additional context in comments.

Comments

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

2 Comments

i have one doubt, don't we need any kind of password, as i am connecting to other server. means in your code no password is mentioned?
@sandeepKumar Set up ssh with private key.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.