Python SSH

When the number of machines you are trying to manage grows there will come a time when you want to do more than just run Python on the local machine; you want to manage servers remotely. If that server is *nix derived then that means SSH.

Python naturally has a module for SSH connections called Paramiko. Installing the Paramiko module  is a straight forward with pip (pip install paramiko) but it has a dependency on the C module PyCrypto. If you are on Windows, the best way to install this is using an installer from VoidSpace.

Once installed you can connect to a server using SSH in just a few lines of code. I could repeat the code from several other blogs here but instead I’ll just point you to an article written for Python Magazine which does a decent job of explaining the basics.

Published by Quackajack

I started off as a programmer, who moved to support (setting up 2 service desks from scratch), then on to system administrator and then into configuration management. Now I combined all these as a DevOps engineer.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.