OpenSSH command not executed

OpenSSH does not execute commands when they are issued from the command line.

I connect from a Win PC to a Win server (2003), using openssh. If I type the name of the bat file from the prompt, it starts. But when I add the command to the ssh command it does not work:

ssh -vvv -i "keyname.key" admin@server "test2.bat"

I've turned on debug mode:

debug1: Sending command: test2.bat
...
test2.bat: not found

Though test2.bat is present, it cannot be found.

I found out that giving "dir" as a command DOES work....

That's because ssh is looking for "test2.bat" on the remote side, where it probably doesn't exist. You have to copy it there first using scp (or something similar) (assuming the remote side knows how to handle Windows Batch files)

It exists on the other side. The other side is a windows 2003 server, so it should know how to execute the file.

Also, when I do not add "test2.bat" to the commandline, but wait for the remote prompt to come up, and I then type "test2.bat", it will run!

Could be because the ssh daemon tries to launch the batch file as a standalone executable (which it isn't). Try this

ssh -vvv -i "keyname.key" admin@server "cmd /c test2.bat"

Great, this works!

Thanks for the quick reply.