You're making an assumption about local vs. remote which is distracting you from the issue.
The shell and kernel execute shell scripts as I've described. There is something else different between your two systems.
It is clear for the diagnostic output that bash lives in different directories on the two systems. The resolution for this is to generally create a symbolic link to the bash executable to allow your scripts to run on any platform.
First, find the location of the bash's on your systems. Choose one of those full paths to use as your default #!/interpreter line in your code. it is typical to see #!/bin/bash, #!/usr/bin/bash, and even #!/usr/local/bin/bash. It all depends on where that distro, package, or source installation located the binary.
Assume you want to use /bin/bash. On all the other systems that do not have /bin/bash, create the symbolic link:
ln -s /path/to/bash/on/this/system /bin/bash
This will allow your scripts to run using the #!/bin/bash interpreter.
Again, ignore the OpenSSH idea - its a red herring. Once SSH has created the remote shell, it is entirely out of the way in terms of the sub-shell that is then running and executing commands on your behalf.
Instead, look *clearly* at, and understand the meaning of your error messages:
-bash: ./test: Permission denied
Anytime you see a permission problem, you should examine the permissions of the file. Since they are not shared with us here, we're left to guessing. But it is clear that the UID in which you are running on that system does not have permission *to do something* to that file. Examine the permissions.
MrC