Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to run a local shell script on a remote computer with SSH. How can I do this?

share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted
ssh user@remotehost "bash -s" < local_script.sh

-s makes bash read from standard input.

share|improve this answer
    
I'll have to remember that. Please let us know if that worked for you, and don't forget to mark the answer as accepted if it did. –  Argusvision Oct 21 '12 at 12:16
2  
You don't need -s, and you only need bash if you really want to force using bash. Usually you can simply ssh user@remotehost < local_script.sh –  janos Feb 6 '13 at 14:17
    
what if local script has operands? –  kmassada Apr 5 at 14:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.