I think the issue has to do with interactive vs. non-interactive modes. When you login with putty or you call plink without specifying a command, then you are in interactive mode.
However, if you specify a command, or a file with a list of commands, then the remote shell will treat your login as non-interactive, and apparently reject your connection.
I'm not exactly sure how the remote decides to treat your login as interactive or not. I would suggest to try one of these options:
Put your commands in a
script.sh
shell script and copy it to the remote server, and run it like this:C:>plink.exe -pw PASSWORD USER@REMOTEHOST "bash /path/to/remote/script.sh"
If you don't want to put the script on the remote server, you can try to redirect local input to the remote bash, but I'm not sure this works in Windows:
C:>plink.exe -pw PASSWORD USER@REMOTEHOST bash < C:\path\to\local\script.sh
In both suggestions the hope is that by sticking bash
there, your shell will be treated as interactive.