Wednesday, May 15, 2013

Control your Windows machines through SSH and Paramiko

1. On the Windows machine:

- Install SSHD using Cywin: check http://www.howtogeek.com/howto/41560/how-to-get-ssh-command-line-access-to-windows-7-using-cygwin/

- Assuming that you create a user name genius with administrator permission, including ssh access.

2. On the other machine which installed python and paramiko module:
Before going further, I prefer you read the following article carefully about paramiko and its capability: jessenoller.com/blog/2009/02/05/ssh-programming-with-paramiko-completely-different

Write the client class which will connect to ssh server (the Windows) and execute command from that server for you, ssh_client.py:






Now run your program in the terminal, for example, query the username genius (if the Windows is also a Domain Controller):

$ python ssh_client.py 'dsquery user -samid genius'