How can I run my local bash script remotely with SSH access?

Could I change the folder before run the script?

1 Answer 1


You can use this command to access your specific folder (e.g. html), then run your local bash script:

ssh user@remote_host 'cd html && bash ' < ../snippets/myCustomBash.sh
  • Checking cd for errors might possibly make more sense with && instead of the assuming it worked with the ;
    – thrig
    Commented Apr 11, 2017 at 20:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .