Search code examples
debianportforwarding

open/forwarding port in debian


I want to connect postgres that is in my vps (debian), from my pc with pgadmin3. my problem is that port 5432 is not open! I tried to open it with this command

iptables -A INPUT -p tcp --dport 5432 -j ACCEPT

but my problem didn't solve!

aminpy@lenovo ~ $ telnet vps_ip 5432
Trying vps_ip...
telnet: Unable to connect to remote host: Connection refused

can anybody help me?


Solution

  • It probably isn't a good idea to open that port to everyone on the internet. I would use a SSH port forward instead which will pass all data transparently through an encrypted tunnel. Use a command like this:

    ssh -L 15432:localhost:5432 vps-host
    

    Connections to port 15432 on your machine will then be forward to port 5432 on vps-host. Note that the localhost in the command is the hostname as seen from vps-host, not your client machine.

    See the man page for ssh for more info.