PostgreSQL SSH Tunnel for Amazon EC2?

I created Amazon EC2 AMI running on CentOS Linux 5.5 and PostgreSQL 8.4. I would like to be able to create an SSH tunnel from my machine to an instance so that I can connect to the PostgreSQL database from my development machine (JDBC, Tomcat, etc.). I have not modified the configuration of PostgreSQL at all though. I can successfully SSH into the instance from the command line and run the following command to try to create my tunnel:

ssh -N -L2345:<My instance DNS>:5432 -i <keypair> root@ <My instance DNS> 

I get no errors when I run this command for the first time. However, when I try to use psql to open a connection on localhost: 2345, the connection fails.

Any thoughts on why this is happening?

+4
source share
1 answer

The first <My instance DNS> should be localhost . And you probably don't want / need ssh as root.

+5
source

Source: https://habr.com/ru/post/1334258/


All Articles