Ssh – How to run a python script on Windows machine from Linux using ssh as a background task

backgroundssh

I have to orchestrate some script tasks among few Linux machines and a Windows machine. ssh works fine for linux machines suing below:

ssh mysuser@targetLinuxmachine "python '/pathtomyscript/myscript.py' &"

But the same method doesn't work as background task when I'm sending the command to an Windows machine.
On the Windows machine, I have ssh server running and the ssh connection itself is working. RSA public key has been inserted too.
In fact below commands runs:

ssh -n -f mysuer@targetwinmachine "python 'C:\Windowspath\myscript.py -someswitch parameter' &"

however executing the command in bash will take my terminal to windows console and doesn't allow me to run it as a back ground task.
I guess "&" is not working on windows to run the command as a background task.

How can I run the equivalent script on a Windows machine as a background task?

Best Answer

Yes, cygwin has a very good ssh server for windows. First you should download and install this.

After you can log into your windows machine with command line ssh, you can use ssh-keygen to make this passwordless and automatic.

The third thing were to install python on your windows machine, which you can get from http://www.python.org/getit/windows/ .

It is for me uncelar, which one of this steps don't work, but probably your main problem is with the ssh server install on your windows machine. Can you log in to your server with commandline ssh from your unix/linux box? If not, please upgrade your question and I will upgrade my answer.