title: Paramiko's SFTP Python connection
body: <p>I'm trying to set up an SFTP connection with Python (v2.7) using Paramiko's library <a href="http://docs.paramiko.org/en/2.1/api/sftp.html" rel="nofollow noreferrer">http://docs.paramiko.org/en/2.1/api/sftp.html</a></p>
  
  <p>From bits and pieces online I was able to (I think so anyway) connect using a private encrypted certificate.</p>
  
  <p>This looks as follows:</p>
  
  <pre><code>import paramiko
  sftp = paramiko.SSHClient()
  
  hostname = "sftp.host.com"
  port = 8022
  username = "sftplogin"
  
  k = paramiko.RSAKey.from_private_key_file("private.pem", password="XXX")
  sftp.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  print "Connecting..."
  sftp.connect(hostname, port, username=username, pkey=k )
  print "Connected to: " + hostname + ":" + port
  print sftp.getcwd()
  sftp.close()
  </code></pre>
  
  <p>At this point, I'm just trying to see if I'm not delusional and in fact did not connect, so I'm attempting to print a getcwd() to get the current directory ... Sadly I'm getting nowhere, as it's returning this error:</p>
  
  <blockquote>
    <p>AttributeError: 'SSHClient' object has no attribute 'getcwd'</p>
  </blockquote>
  
  <p>Can anyone tell me why? What am I doing wrong?</p>
  
  <p>Thanks in advance!</p>