title: Airflow Can't Connect to SFTP with SSH Private Key
body: <p>I am trying to use the SFTP Operator/Hook with a SSH private key instead of a password.</p>
  <p>My connection has the following extra arguments: <code>{&quot;key_file&quot;: &quot;/home/airflow/key_files/some_key&quot;, &quot;no_host_key_check&quot;: &quot;true&quot;}</code>. My SSH Private key looks like the following:</p>
  <pre><code>-----BEGIN OPENSSH PRIVATE KEY-----
  ...
  -----END OPENSSH PRIVATE KEY-----
  </code></pre>
  <p>Now when I try to create a hook I get the following error:</p>
  <pre><code>&gt;&gt;&gt; from airflow.contrib.hooks.sftp_hook import SFTPHook
  &gt;&gt;&gt; s = SFTPHook(ftp_conn_id='my_sftp_connection')
  [2020-07-08 13:40:25,449] {base_hook.py:84} INFO - Using connection to: id: my_sftp_connection. Host: my_sftp.com, Port: 22, Schema: None, Login: user, Password: None, extra: {'key_file': '/home/airflow/key_files/some_key', 'no_host_key_check': 'true'}
  [2020-07-08 13:40:25,452] {base_hook.py:84} INFO - Using connection to: id: my_sftp_connection. Host: my_sftp.com, Port: 22, Schema: None, Login: user, Password: None, extra: {'key_file': '/home/airflow/key_files/some_key', 'no_host_key_check': 'true'}
  &gt;&gt;&gt; s.list_directory('/')
  Traceback (most recent call last):
    File &quot;/home/airflow/.local/lib/python3.6/site-packages/pysftp/__init__.py&quot;, line 167, in _set_authentication
      private_key_file, private_key_pass)
    File &quot;/home/airflow/.local/lib/python3.6/site-packages/paramiko/pkey.py&quot;, line 206, in from_private_key_file
      key = cls(filename=filename, password=password)
    File &quot;/home/airflow/.local/lib/python3.6/site-packages/paramiko/rsakey.py&quot;, line 55, in __init__
      self._from_private_key_file(filename, password)
    File &quot;/home/airflow/.local/lib/python3.6/site-packages/paramiko/rsakey.py&quot;, line 175, in _from_private_key_file
      data = self._read_private_key_file(&quot;RSA&quot;, filename, password)
    File &quot;/home/airflow/.local/lib/python3.6/site-packages/paramiko/pkey.py&quot;, line 279, in _read_private_key_file
      data = self._read_private_key(tag, f, password)
    File &quot;/home/airflow/.local/lib/python3.6/site-packages/paramiko/pkey.py&quot;, line 289, in _read_private_key
      raise SSHException(&quot;not a valid &quot; + tag + &quot; private key file&quot;)
  paramiko.ssh_exception.SSHException: not a valid RSA private key file
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
    File &quot;/home/airflow/.local/lib/python3.6/site-packages/airflow/contrib/hooks/sftp_hook.py&quot;, line 151, in list_directory
      conn = self.get_conn()
    File &quot;/home/airflow/.local/lib/python3.6/site-packages/airflow/contrib/hooks/sftp_hook.py&quot;, line 114, in get_conn
      self.conn = pysftp.Connection(**conn_params)
    File &quot;/home/airflow/.local/lib/python3.6/site-packages/pysftp/__init__.py&quot;, line 142, in __init__
      self._set_authentication(password, private_key, private_key_pass)
    File &quot;/home/airflow/.local/lib/python3.6/site-packages/pysftp/__init__.py&quot;, line 171, in _set_authentication
      private_key_file, private_key_pass)
    File &quot;/home/airflow/.local/lib/python3.6/site-packages/paramiko/pkey.py&quot;, line 206, in from_private_key_file
      key = cls(filename=filename, password=password)
    File &quot;/home/airflow/.local/lib/python3.6/site-packages/paramiko/dsskey.py&quot;, line 65, in __init__
      self._from_private_key_file(filename, password)
    File &quot;/home/airflow/.local/lib/python3.6/site-packages/paramiko/dsskey.py&quot;, line 224, in _from_private_key_file
      data = self._read_private_key_file(&quot;DSA&quot;, filename, password)
    File &quot;/home/airflow/.local/lib/python3.6/site-packages/paramiko/pkey.py&quot;, line 279, in _read_private_key_file
      data = self._read_private_key(tag, f, password)
    File &quot;/home/airflow/.local/lib/python3.6/site-packages/paramiko/pkey.py&quot;, line 289, in _read_private_key
      raise SSHException(&quot;not a valid &quot; + tag + &quot; private key file&quot;)
  paramiko.ssh_exception.SSHException: not a valid DSA private key file
  </code></pre>
  <p>What am I doing wrong here? That same SSH key works with WINSCP and the SFTP command in bash.</p>