Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pymysql, shlex, shutil, subprocess
- import logging
- import sshtunnel
- from sshtunnel import SSHTunnelForwarder
- import iot_config as cfg
- def OpenRemoteDB():
- global remotecur, remotedb
- sshtunnel.DEFAULT_LOGLEVEL = logging.DEBUG
- with SSHTunnelForwarder(
- (cfg.sshconn['host'], cfg.sshconn['port']),
- ssh_username = cfg.sshconn['user'],
- ssh_private_key = cfg.sshconn['private_key_loc'],
- ssh_private_key_password = cfg.sshconn['private_key_passwd'],
- remote_bind_address = ('127.0.0.1', 3306)) as server:
- print("OK")
- # Main program starts here
- OpenRemoteDB()
- 2016-09-20 12:34:15,272 | WARNING | Could not read SSH configuration file: ~/.ssh/config
- 2016-09-20 12:34:15,305 | INFO | 0 keys loaded from agent
- 2016-09-20 12:34:15,332 | DEBUG | Private key file (/etc/ssh/my_private_key.key, <class 'paramiko.rsakey.RSAKey'>) successfully loaded
- 2016-09-20 12:34:15,364 | INFO | Connecting to gateway: mysite.co.uk:22 as user 'user'
- 2016-09-20 12:34:15,389 | DEBUG | Concurrent connections allowed: True
- 2016-09-20 12:34:15,409 | DEBUG | Trying to log in with key: b'XXX'
- 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