27
rated 0 times
[
27]
[
0]
/ answers: 1 / hits: 38893
/ 2 Years ago, tue, june 15, 2021, 11:07:40
I want to run a local shell script on a remote computer with SSH. How can I do this?
More From » command-line
I want to run a local shell script on a remote computer with SSH. How can I do this?
ssh user@remotehost "bash -s" < local_script.sh
-s
makes bash read from standard input.
If you need to pass arguments to your script:
ssh user@remotehost "bash -s" -- < local_script.sh "your_arg" "--aswitch" "avalue"
Note the double dash --
(signifying the end of the command options) and the quotes around the arguments.