3

I would like to connect to a Postgres server installed on a remote server using an ssh tunnel. I have Windows so I use cygwin for SSH.

I do the following on cygwin:

# Create the tunnel
ssh -f user@remote_server -p ssh_port -L 5433:127.0.0.1:5432 -N

On pgAdmin, I set the host to localhost and the port to 5433 as well as the username/password/db.

When I try to connect, it is running, and then it displays an error message:

Error connecting to the server: server closed the connection unexpectedly.

On cygwin, I see this message:

Write failed: Broken pipe

The ssh process has actually been killed so I guess it crashed? But why?

How could I get more information to know what the problem is and especially where (pgadmin or ssh tunnel on cygwin...) ?

Thanks

3
  • In general it's going to be a lot less painful to use PuTTY. The plink tool supports tunnels, or you can use a saved profile in PuTTY. Commented Dec 5, 2014 at 1:52
  • Yes I know and I'd like to use PuTTY but I could not convert my key because it uses the new format. :-/ Commented Dec 5, 2014 at 2:01
  • Since my key was generated with ssk-keygen -o (openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man1/ssh-keygen.1) I cannot conver it with puttygen to use it with putty so that is why I wanted to use openssh from within cygwin directly but I do not know whether the issue is on cygwin or pgadmin or even my server..? Commented Dec 5, 2014 at 3:05

1 Answer 1

2

I was finally able to make it work by removing the -f option when creating the SSH tunnel.

For an unknown reason, the error appears when using the -f option but it works fine otherwise and I can connect via pgAdmin using the SSH tunnel.

1
  • Maybe it has something to do with this (from the man page for ssh)? If the ExitOnForwardFailure configuration option is set to “yes”, then a client started with -f will wait for all remote port forwards to be successfully established before placing itself in the background. Commented Oct 27, 2016 at 17:34

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.