-- Microsoft Windows [Version 10.0.18362.592] (c) 2019 Microsoft Corporation. All rights reserved. C:\Users\umshastr>cd C:\Work\Apps\Setups\OpenSSH-Win64 C:\Work\Apps\Setups\OpenSSH-Win64>ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (C:\Users\umshastr/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in C:\Users\umshastr/.ssh/id_rsa. Your public key has been saved in C:\Users\umshastr/.ssh/id_rsa.pub. The key fingerprint is: SHA256:fy4MA7b7VdIOvjQBWX3YJyXtu/t9xnziZiyCd2oZgfQ umshastr@UMSHASTR-IN The key's randomart image is: +---[RSA 3072]----+ | .. o.o.| | .o o +.o| | .oo . + | | o ..E. .| | . oS +.o .| | . oo.* . | | . =*oo. o.| | . .oB=o =.B| | ..oo=.=.+B| +----[SHA256]-----+ C:\Work\Apps\Setups\OpenSSH-Win64> -- append public key in OL7 where MySQL Server is running -- Confirm that able to connect C:\Work\Apps\Setups\OpenSSH-Win64>ssh umshastr@AbCYY.no.oracle.com Warning: Permanently added the ED25519 host key for IP address 'AbCYY' to the list of known hosts. Last login: Fri Jan 31 06:46:28 2020 from AbCZZ [umshastr@AbCYY]~: ---------- import platform import mysql.connector import paramiko import pandas as pd from paramiko import SSHClient from sshtunnel import SSHTunnelForwarder from os.path import expanduser mypkey = paramiko.RSAKey.from_private_key_file("C:\\Users\\umshastr\\.ssh\\id_rsa") sql_hostname = 'localhost' sql_username = 'root' sql_password = '' sql_main_database = 'test' sql_port = 3333 ssh_host = 'AbCYY.no.oracle.com' ssh_user = 'umshastr' ssh_port = 22 tunnel = SSHTunnelForwarder( (ssh_host, ssh_port), ssh_username=ssh_user, ssh_pkey=mypkey, remote_bind_address=(sql_hostname, sql_port)) tunnel.daemon_forward_servers = True print("Python version: {}". format(platform.python_version())) print("Driver: {} {}".format(mysql.connector.__name__,mysql.connector.__version__)) print('Starting..') tunnel.start() print(tunnel.local_bind_port) print(tunnel.is_active) conn = mysql.connector.connect(host='localhost', user=sql_username, passwd=sql_password, db=sql_main_database, port=tunnel.local_bind_port) print("I'm here...") df = pd.read_sql("SELECT version(),user(),NOW();", conn) print(df) conn.close() tunnel.stop() tunnel.close() print('Ending..') ######### Python version: 2.7.16 Driver: mysql.connector 8.0.19 Starting.. 53766 True I'm here... version() user() NOW() 0 8.0.19 root@localhost 2020-02-03 10:41:21 Ending.. Press any key to continue . . . ######### Python version: 3.8.0 Driver: mysql.connector 8.0.19 Starting.. 58560 True I'm here... version() user() NOW() 0 5.6.47 root@localhost 2020-02-03 13:56:37 Ending.. Press any key to continue . . . ######### Python version: 3.7.5 Driver: mysql.connector 8.0.19 Starting.. 58579 True ^^ hangs here