in reply to Pass local bash script to remote host via SSH
In addition to this, there is nothing wrong with uploading a script file directly into $HOME/tmp then executing that script. In many ways this is much more clear and will be more easily understood by your future self during any maintenance of this program.
Finally be sure to protect the script appropriately, for example I would not blindly upload it to /tmp and I would ensure that only the remote system $USER is able to read the script. Also, clean up after by deleting the script.
For additional security, you may pass sensitive values to the script via the environment using the equivalent of ssh -o SendEnv=MYVAR directly or in your code. Any passwords or other secrets may be provided to the script this way and the script would just make use of them assuming they are defined. Do not send them to the script via commandline argument or by explicitly setting the value in the ssh command itself.
|
|---|