Run local script over ssh
If Server A is a Unix/Linux-based system, you can use:
ssh root@MachineB 'bash -s' < local_script.sh
You shouldn't have to copy the script to the remote server to run it.
Use this command:
ssh user@host <<'my.sh'
#script to run on remote host
my.sh