0

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

ssh USER@HOST 'COMMAND'

run a script

ssh root@192.168.1.1 '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?

2

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:

#!/bin/bash
seq 1 10
  • Yes - rolled back the suggested edit. – Fiximan May 29 at 14:56
  • Noted. :) comment deleted. – Jim L. May 29 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.