title: Paramiko -- using encrypted private key file on OS X
body: <p>I'm trying to use Paramiko to connect to an SSH server from Python. This is what I tried so far:</p>
  
  <pre><code>&gt;&gt;&gt; import paramiko
  &gt;&gt;&gt; import os
  &gt;&gt;&gt; privatekeyfile = os.path.expanduser('~/.ssh/id_rsa')
  &gt;&gt;&gt; mykey = paramiko.RSAKey.from_private_key_file(privatekeyfile)
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/paramiko/pkey.py", line 198, in from_private_key_file
      key = cls(filename=filename, password=password)
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/paramiko/rsakey.py", line 51, in __init__
      self._from_private_key_file(filename, password)
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/paramiko/rsakey.py", line 163, in _from_private_key_file
      data = self._read_private_key_file('RSA', filename, password)
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/paramiko/pkey.py", line 280, in _read_private_key_file
      data = self._read_private_key(tag, f, password)
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/paramiko/pkey.py", line 323, in _read_private_key
      raise PasswordRequiredException('Private key file is encrypted')
  paramiko.PasswordRequiredException: Private key file is encrypted
  </code></pre>
  
  <p>As you can see, it's failing because my private key is encrypted. However, the password is stored in my OS X login keychain, and when I type <code>ssh host</code> it won't ask for it (rather, it only asks once, then remembers it until the next reboot). Is there a way to make <code>paramiko</code> use the password / fetch it from the keychain, like <code>ssh</code> does?</p>