I've seen that it's possible to run scripts stored locally on a remote server eg.: run a command:


run a script

ssh root@ 'bash -s' < script.sh

What about doing it on the oppisite way?

Is it possible to get a script stored on a remote server and execute it locally?

1 Answer 1


Yes, you essentially can read the script file in:

bash -c "$( ssh user@remote_host "cat /path/to/script.sh" )"

Worked well with this minimal thing:

seq 1 10
  • Yes - rolled back the suggested edit.
    – FelixJN
    May 29, 2019 at 14:56
  • Noted. :) comment deleted.
    – Jim L.
    May 29, 2019 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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