Say I have the following Bash script stored in the file foo.sh:
foo.sh
#!/bin/bash echo foo
Without having to scp the fi
scp
cat foo.sh | ssh -T root@remote will to the trick. The -T option suppresses a warning you would otherwise get because you're piping input from a file.
cat foo.sh | ssh -T root@remote
-T