I do not understand why I can connect to a Mysql DB via SSH and Sequel Pro but if I am trying this with Python I can't establish a connection.
Everything works fine when I open Sequel Pro and filling the following data in the boxes:
MySQL-Host: 127.0.0.1
User: db_username
Password: db_password
Database: database
Port: 3306
SSH-Host: ssh_ip_adress
SSH-User: ssh_user
SSH-Password: ssh_password
SSH-Port: 22
but when I try this in Python
import pymysql
from sshtunnel import SSHTunnelForwarder
with SSHTunnelForwarder(
('ssh_ip_adress', 22),
ssh_username="ssh_user",
ssh_password="ssh_password",
remote_bind_address=(127.0.0.1, 3306)
) as tunnel:
port = tunnel.local_bind_port
db_connection = pymysql.connect(
host='ssh_ip_adress', port=port, db='database', user='db_username',
password='db_password', charset='utf8mb4')
I receive an error:
sshtunnel.BaseSSHTunnelForwarderError: Could not establish session to SSH gateway
What can I do?