I can establish an SSH tunnel using ssh -L 2222:<RDS-Endpoint>:5432 ec2-user@<EC2-IP> -i ~/.ssh/key.pem
and then connect to my RDS using psql "host=localhost port=2222 user=postgres password=<pw>
These same settings in pgAdmin 4 do not seem to work.
- Host name in connection tab =
<RDS-Endpoint>
- Tunnel host =
<EC2-IP>
- Port in connection tab = 5432
- Port in SSH tunnel tab = 2222
- Username in connection tab = postgres
- Username in ssh tunnel tab = ec2-user
- Password in connection tab =
<pw>
- And identity file in ssh tunnel tab = ~/.ssh/key.pem
After trying for a while pgAdmin 4 fails with: unable to connect to server: Failed to create the SSH Tunnel. Error: Could not establish session to SSH gateway
cat ~/.pgadmin/pgadmin4.log
Just gives me:
ERROR pgadmin: Could not establish session to SSH gateway
Traceback (most recent call last):
File "/usr/pgadmin4/web/pgadmin/utils/driver/psycopg3/server_manager.py", line 610, in create_ssh_tunnel
self.tunnel_object.start()
File "/usr/pgadmin4/venv/lib/python3.10/site-packages/sshtunnel.py", line 1331, in start
self._raise(BaseSSHTunnelForwarderError,
File "/usr/pgadmin4/venv/lib/python3.10/site-packages/sshtunnel.py", line 1174, in _raise
raise exception(reason)
sshtunnel.BaseSSHTunnelForwarderError: Could not establish session to SSH gateway
I'm really lost on how to proceed given it works via the terminal. So clearly not some security group issue on AWS's side. I've tried deleting ~/.pgadmin
and trying again, but same result. Any help appreciated thanx.
In case this helps:
lsb_release -a
No LSB modules are available.
Distributor ID: Pop
Description: Pop!_OS 22.04 LTS
Release: 22.04
Codename: jammy