简体   繁体   中英

PostgreSQL SSH Tunnel to Amazon EC2?

I've created an Amazon EC2 AMI running CentOS Linux 5.5 and PostgreSQL 8.4. I'd like to be able to create an SSH tunnel from my machine to the instance so I can connect to the PostgreSQL database from my development machine (JDBC, Tomcat, etc.) I haven't modified the PostgreSQL configuration at all as of yet. I can successfully SSH into the instance from a command line, and have run the following command to try and create my tunnel:

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

I don't receive any errors when initially running this command. However, when I try and use psql to open up a connection on localhost:2345, the connection fails.

Any thoughts as to why this is happening?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM