title: Paramiko - connect with private key - not a valid OPENSSH private/public key file
body: <p>I am trying to find the solution to this and can't understand what I'm doing wrong.</p>
  <p>On my Linux server I have run the following command:</p>
  <pre><code>ssh-keygen -t rsa
  </code></pre>
  <p>This generated an <code>id_rsa</code> and <code>id_rsa.pub</code> file.</p>
  <p>I then copied them both locally and attempted to run the following code:</p>
  <pre><code>    ssh = paramiko.SSHClient()
      ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
      ssh.connect('myserver', username='myuser', key_filename='id_rsa')
      sftp = ssh.open_sftp()
      sftp.chdir('/path/to/file')
      sftp.get(file, os.path.join(tmp_dir, '{0}.existing-{1}'.format('myfile', current_datetime)))
  except Exception, err:
      logging.debug(err)
      logging.info('Error connecting to Host')
  </code></pre>
  <p>I get the following error in my log:</p>
  <pre><code>2017-08-22 22:41:54,486 Switch to new keys ...
  2017-08-22 22:41:54,502 Adding ssh-ed25519 host key for myserver.domain.com: 51ac2fe875499371256dd8c5a132f394
  2017-08-22 22:41:54,502 Trying key 7688e32d30edb2c94bfe39be9897004f from id_rsa
  2017-08-22 22:41:54,532 userauth is OK
  2017-08-22 22:41:54,549 Authentication (publickey) failed.
  2017-08-22 22:41:54,563 not a valid OPENSSH private key file
  2017-08-22 22:41:54,563 Error connecting to Host
  2017-08-22 22:41:54,657 EOF in transport thread
  </code></pre>
  <p>am I missing something?  It is a valid OPENSSH private key file.</p>
  <p>edit - if I use the <code>id_rsa.pub</code> I get the following:</p>
  <pre><code>2017-08-22 22:58:09,631 Kex agreed: ecdh-sha2-nistp256
  2017-08-22 22:58:09,631 HostKey agreed: ssh-ed25519
  2017-08-22 22:58:09,631 Cipher agreed: aes128-ctr
  2017-08-22 22:58:09,631 MAC agreed: hmac-sha2-256
  2017-08-22 22:58:09,631 Compression agreed: none
  2017-08-22 22:58:09,694 kex engine KexNistp256 specified hash_algo &lt;built-in function openssl_sha256&gt;
  2017-08-22 22:58:09,710 Switch to new keys ...
  2017-08-22 22:58:09,726 Adding ssh-ed25519 host key for myserver.domain.com: 51ac2fe875499371256dd8c5a132f394
  2017-08-22 22:58:09,726 not a valid OPENSSH private key file
  2017-08-22 22:58:09,726 Error connecting to Host
  2017-08-22 22:58:09,819 EOF in transport thread
  </code></pre>
  <p>Why?</p>