Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. import pymysql, shlex, shutil, subprocess
  2. import logging
  3. import sshtunnel
  4. from sshtunnel import SSHTunnelForwarder
  5. import iot_config as cfg
  6.  
  7. def OpenRemoteDB():
  8. global remotecur, remotedb
  9. sshtunnel.DEFAULT_LOGLEVEL = logging.DEBUG
  10. with SSHTunnelForwarder(
  11. (cfg.sshconn['host'], cfg.sshconn['port']),
  12. ssh_username = cfg.sshconn['user'],
  13. ssh_private_key = cfg.sshconn['private_key_loc'],
  14. ssh_private_key_password = cfg.sshconn['private_key_passwd'],
  15. remote_bind_address = ('127.0.0.1', 3306)) as server:
  16. print("OK")
  17.  
  18. # Main program starts here
  19. OpenRemoteDB()
  20.  
  21. 2016-09-20 12:34:15,272 | WARNING | Could not read SSH configuration file: ~/.ssh/config
  22. 2016-09-20 12:34:15,305 | INFO | 0 keys loaded from agent
  23. 2016-09-20 12:34:15,332 | DEBUG | Private key file (/etc/ssh/my_private_key.key, <class 'paramiko.rsakey.RSAKey'>) successfully loaded
  24. 2016-09-20 12:34:15,364 | INFO | Connecting to gateway: mysite.co.uk:22 as user 'user'
  25. 2016-09-20 12:34:15,389 | DEBUG | Concurrent connections allowed: True
  26. 2016-09-20 12:34:15,409 | DEBUG | Trying to log in with key: b'XXX'
  27. 2016-09-20 12:35:26,610 | INFO | Opening tunnel: 0.0.0.0:34504 <> 127.0.0.1:3306
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement