Remote Code Execution on Windows Server From a Linux Server
A quick tutorial on how to execute scripts on a Windows server remotely from a Linux server using the Python module Paramiko.
Join the DZone community and get the full member experience.Join For Free
Let's say a Workflow Management Framework of our choice based on the business needs works only on Linux. And let's say our jobs/scripts depend on some libraries that are only compatible with Windows. One of the solutions here could be to host the Workflow Management Framework on a Linux server and execute the jobs on a Windows server via SSH. So the jobs will be triggered on the Linux server and executed on the Windows server.
Paramiko is a Python implementation of the SSH protocol, providing both client and server functionality. It is a Python interface around SSH networking concepts. http://www.paramiko.org/
Let's get started.
Make sure SSH is enabled on both the servers.
Install the Paramiko module on the Linux server.
On the Windows server, create a python file (winser_test.py) and add the below sample code.
On the Linux server, create a python file (linser_test.py) and add the below client code.
Now, execute the linser_test.py script and that will in turn execute the winser_test.py on the Windows server.
Opinions expressed by DZone contributors are their own.