Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 7 down vote accepted
ssh user@remotehost "bash -s" <

-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
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 < – janos Feb 6 '13 at 14:17
what if local script has operands? – kmassada Apr 5 '14 at 14:06

Your Answer


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.