title: Open SSH connection on exit Python
body: <p>I am writing a little script which picks the best machine out of a few dozen to connect to. It gets a users name and password, and then picks the best machine and gets a hostname. Right now all the script does is print the hostname. What I want is for the script to find a good machine, and open an ssh connection to it with the users provided credentials.</p>
  
  <p>So my question is how do I get the script to open the connection when it exits, so that when the user runs the script, it ends with an open ssh connection.</p>
  
  <p>I am using sshpass.</p>