Month: September 2015

Learning the Python library

My motivation for starting this blog was to make a note of useful Python code I’ve discovered or written so I could easily find it again. It also has the added benefit of forcing me to understand the libraries I’m using so I can explain them and write concise examples.

Another person who used a blog to start something is Doug Hellmann. He created the Python Module of the Week blog to get in the habit of writing something on a regular basis. The blog focuses on Python’s standard library and includes some very good examples.

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.