I already have an ssh agent set up, and I can run commands on an external server in Bash script doing stuff like:
ssh blah_server "ls; pwd;"
This can also be done as follows. Put your commands in a script, let's name it commands-inc.sh
#!/bin/bash ls some_folder ./someaction.sh pwd
Save the file
Now run it on the remote server.
ssh user@remote 'bash -s' < /path/to/commands-inc.sh
Never failed for me.