python rds通过ssh隧道连接到aws rds的问题

问题描述 投票:0回答:0

我有使用 ssh 隧道连接 rds 数据库的代码如下 但我在建立隧道后一直坚持连接。 有人可以帮助我吗? 嗯..隧道是成功的。但卡住了。 code.help后日志如下!!!!!! 以及现在用于 DBeaver 的 pem 文件的其他信息。

with SSHTunnelForwarder(
        ('15.164.xxx.xxx',22),  # SSH host and port
        ssh_username='ec2-user',  # SSH user_name
        ssh_pkey='key-stg-evchg-xxxxxxxxxx.pem',
        remote_bind_address=('rds-stg-evchg-cluster.cluster-xxxxxxxxxxxxxx.ap-northeast-2.rds.amazonaws.com', 3306)) as tunnel:
    print(tunnel)

    conn = pymysql.connect(
        host="127.0.0.1",
        port=tunnel.local_bind_port,
        user="user",
        password="password"
    )

以下是隧道信息

<class 'sshtunnel.SSHTunnelForwarder'> object
ssh gateway: 15.164.xxx.xxx:22
proxy: no
username: ec2-user
authentication: {'pkeys': [('ssh-rsa', b'7295dd6621412412312312fedf')]}
hostkey: not checked
status: started
keepalive messages: every 5.0 sec
tunnel connection check: disabled
concurrent connections: allowed
compression: not requested
logging level: ERROR
local binds: [('0.0.0.0', 0)]
remote binds: [('rds-stg-evchg-cluster.cluster-cvrtu5pd6rrl.xxxxxxxxxx.amazonaws.com', 3306)]
mysql amazon-web-services ssh amazon-rds tunnel
© www.soinside.com 2019 - 2024. All rights reserved.