Glam Prestige Journal

Bright entertainment trends with youth appeal.

I have a bash script on Machine B which I want to run on Machine B. I am using Machine A right now. Is this possible?

So far I've only managed to do it if the script lives on Machine A using the following command:

ssh user@machineb 'bash -s' < /path/machinea/script.sh

I don't want to have to copy this remote script locally. Is there a way to run this remote script on a remote machine through my local machine via SSH?

1

1 Answer

From man ssh:

If command is specified, it is executed on the remote host instead of a login shell.

where command is the last argument of ssh

Therefore, the only thing you have to do is move the single quote:

ssh user@machineb 'bash -s < /path/machinea/script.sh'

Basically the command you provided above redirects the machine A script to ssh, which transmits the script through the network and runs it in machine B. Even less hassle to run scripts/commands locally on machine B.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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