Sunday, 15 September 2024

How to Run a Local Shell Script on a Remote Machine via SSH

If you want to run a local shell script on a remote machine using SSH, there are several ways to achieve this depending on whether you’re using a Windows or Unix-based system. Here’s a guide for both environments:

For Unix-Based Systems (Linux/macOS)

You can use ssh to execute a local shell script on a remote machine without needing to copy the script over. The command works by sending the script via standard input to be executed on the remote server:

ssh user@MachineB 'bash -s' < local_script.sh
Read more »

Labels: