I was able to invoke a shell script using this command:
ssh ${serverhost} "./sh/checkScript.ksh"
Of course, checkScript.ksh
must exist in the $HOME/sh
directory.
If you want to execute a local script remotely without saving that script remotely you can do it like this:
cat local_script.sh | ssh user@remotehost 'bash -'
It works like a charm for me.
I do that even from Windows to Linux given that you have MSYS installed on your Windows computer.
Make the script executable by the user "Kev" and then remove the try it running through the command
sh kev@server1 /test/foo.sh
I don't know if it's possible to run it just like that.
I usually first copy it with scp and then log in to run it.
scp foo.sh user@host:~
ssh user@host
./foo.sh
You can do:
ssh user@host 'bash -s' < /path/script.sh
Source: Stackoverflow.com