Last updated 8 months ago
Typically on SSH connection, we run commands on the remote server, but in order to run a local script on the remote server we can use bash -s which expects input from standard input, and runs the script in shell session.
bash -s
$ ssh user@remotehost 'bash -s' < script.sh
Source: