title: Using ssh_config file with Paramiko
body: <p>I need to connect to a server with SSH to download files. I have Ubuntu and I've set up SSH in the standard way: I have a <code>ssh_config</code> file in <code>.ssh</code> which defines a host entry (say <code>host_key</code>) for the server address (<code>Hostname.com</code>) and username, and I've set up an RSA key. So when I try to log into SSH from the command line or bash, I just need to use <code>ssh host_key</code></p>
  
  <p>I would like to do this in Python. The standard solutions seems to be to use Paramiko to set up the connection. I tried this:</p>
  
  <pre><code>from paramiko import SSHClient
  from scp import SCPClient
  
  ssh = SSHClient()
  ssh.load_system_host_keys()
  ssh.connect('host_key')
  
  scp = SCPClient(ssh.get_transport())
  # etc...
  </code></pre>
  
  <p>However, it always seems to hang and time out on <code>ssh.connect('host_key')</code>. Even when I try to include the username and password: <code>ssh.connect('host_key', username='usrnm', password='pswd')</code>.</p>
  
  <p>Are my host keys not loading properly? And would this take care of the RSA keys as well?</p>
  
  <p>It only works if I use the whole <code>Hostname.com</code> with username and typed-out password. Which is maybe a bit insecure.</p>