if __name__ == "__main__": hostname = 'xxx' port = 22 username = 'xxx' password = 'xxx'
s = paramiko.SSHClient() s.set_missing_host_key_policy(paramiko.AutoAddPolicy()) s.connect(hostname, port, username, password)
sftp_client = s.open_sftp() remote_file = sftp_client.open('/tmp/file') try: for line in remote_file: print line finally: remote_file.close() s.close()