I have a script.sh
stored on remote server at some directory, which I want to run from a local computer.
How can I do that in unix
using ssh
?
I have a script.sh
stored on remote server at some directory, which I want to run from a local computer.
How can I do that in unix
using ssh
?
You can use ssh
command from the local server to execute commands on the remote server. You just have to do something like this:
ssh [user]@[server] '[command]'
In your case, you are trying to execute a shell-script. You can use the same method in the following way:
ssh [user]@[server] /location/of/your/script.sh
You can also run multiple commands in this way:
ssh [user]@[server] '[command 1]; [command 2]; [command 3]'
Or you can also do something like this:
ssh [user]@[server] << EOF
command 1
command 2
command 3
EOF
I assume you have ssh access to your remote server. Type this in a terminal at the local server:
ssh user@remote-server /path/to/script.sh