I am trying to write a python script to update DDL in an Aurora RDS (postgres) on AWS. To do this, I need SSHTunnel to a Linux box which is on the edge of the VPC, then to make another jump to the RDS server. When I connect to RDS via the psql client on the Linux Box, I can connect correctly. But, when I try to sshtunnel via SSHTunnelForwarder in python, I get an error saying:
sshtunnel.BaseSSHTunnelForwarderError: Could not establish session to SSH gateway
Here is my code:
with SSHTunnelForwarder( (LinuxBoxHost,22), ssh_username='ubuntu', ssh_pkey="/path/to/.pem file", remote_bind_address=(RDSHostName,5432)) as server: server.start() print(server.local_bind_port)
I can not even test my connection to the RDS database because I can not touch the Linux Box via SSH.
I do not know what I'm doing wrong here. I have looked at various examples online, and it appears that the parameters I am entering appear to be correct.
–Can SSH -i via the command line to the linux box very well
–Can connect to RDS via DBeaver, which also uses a .pem file for ssh tunnel
–Check syslog and auth.log, but there is no useful error information in both.
I wonder if I'm just missing something conceptual here? Is it only possible? Maybe the way I imagine our network infrastructure is not correct, but I spoke to our IT specialist and it seems to me that I have the right idea. Any advice would be appreciated, thanks in advance!