title: Can't connect SSH with paramiko to a Google Compute Engine instance
body: <p>I found a lot of similar questions here in SO, but any of them helped me, even this problem seems to be simple.</p>
  
  <p>I'm trying to connect to a remote Google Compute Engine instance through SSH (I want to use SFTP) using paramiko. Below is my code:</p>
  
  <pre><code>        client = paramiko.SSHClient()
          client.load_system_host_keys()
          client.connect('External_IP_Get_In_GCE_panel', username='myuser')
          stdin, stdout, stderr = client.exec_command('ls')
          for line in stdout:
              print('... ' + line.strip('\n'))
          client.close()
  </code></pre>
  
  <p>With this code, I have the error</p>
  
  <blockquote>
    <p>PasswordRequiredException: Private key file is encrypted</p>
  </blockquote>
  
  <p>When I tried <code>client.connect('External_IP_Get_In_GCE_panel', username='myuser', password='')</code> the error is:</p>
  
  <blockquote>
    <p>BadAuthenticationType: ('Bad authentication type', [u'publickey']) (allowed_types=[u'publickey'])</p>
  </blockquote>
  
  <p>My SSH key to access Google Compute engine has no password. I can use the <code>gcloud compute ssh instance-name</code> and also access SFTP throug Filezilla without problems.</p>
  
  <p>As I said, I tried a lot of alternatives found here in SO, but any of them helped me. Below are 3 other versions of the code:</p>
  
  <p><em>Using key</em></p>
  
  <pre><code>    key = paramiko.RSAKey(data=base64.b64decode(b"""AAAAB3Nza..."""))
      client = paramiko.SSHClient()
      client.get_host_keys().add('External_IP_Get_In_GCE_panel', 'ssh-rsa', key)
      client.connect('External_IP_Get_In_GCE_panel', username='myuser', password='')
      # I got the key using ssh-keyscan `External_IP_Get_In_GCE_panel`in my local machine
  </code></pre>
  
  <p><em>Using another lib</em></p>
  
  <pre><code>    key = paramiko.RSAKey(data=decodebytes(keydata))
      cnopts = pysftp.CnOpts()
      cnopts.hostkeys.add('External_IP_Get_In_GCE_panel', 'ssh-rsa', key)
  
      with pysftp.Connection('External_IP_Get_In_GCE_panel', username='myuser', cnopts=cnopts) as sftp:
          with sftp.cd('../directory'):
              sftp.get('remote_file')'''
  </code></pre>
  
  <p>Using the ssh key file</p>
  
  <pre><code>    self.client = paramiko.SSHClient()
      self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
      self.client.connect(hostname="External_IP_Get_In_GCE_panel", username="myuser", key_filename=os.path.expanduser('~/.ssh/ssh_key_file'), password='') # also tried ssh_key_file.pub
  </code></pre>
  
  <p>In all this versions (and some others) I tried to use <code>password=''</code>, <code>password=None</code> and not send password argument. The results is always the same erros above.</p>
  
  <p>Any tip about what I'm doing wrong?</p>