Wednesday, April 24, 2024
27
rated 0 times [  27] [ 0]  / answers: 1 / hits: 38962  / 3 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

 Answers
7
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.


[#34810] Wednesday, June 16, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
zombieptu

Total Points: 490
Total Questions: 121
Total Answers: 108

Location: Nepal
Member since Mon, Jan 4, 2021
3 Years ago
;