Guest User

Untitled

a guest
Jun 27th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. try:
  2.  
  3. ssh_client=paramiko.SSHClient()
  4. pk=paramiko.RSAKey.from_private_key_file(path)
  5. ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  6. ssh_client.connect(hostname=hostname, port=port, username=username, password=password,pkey=pk)
  7. ssh_stdin, ssh_stdout, ssh_stderr = ssh_client.exec_command(postgresquery)
  8.  
  9.  
  10. print('Tunnel connected')
  11. for line in ssh_stdout.readlines(): #terminal never get past this line of code. And is not either possible to terminate the script
  12. print(line)
  13. ssh_client.close()
  14. except:
  15. print("Connection failed")
Add Comment
Please, Sign In to add comment