ssh -i private_linux_key user@machine "exit 1" || echo %errorlevel%
This always prints
0. How can I get actual error code returned by ssh?
|| somehow detects that there was an error.
I've found a solution, thanks to following question: http://stackoverflow.com/questions/11554324/batch-file-errorlevel-issue
Or even simplier
The latter is possible only when there are no more additional script lines after
To read more about