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
1 Answer 1
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.
-
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.Randall– Randall2016年10月27日 17:34:23 +00:00Commented Oct 27, 2016 at 17:34
Explore related questions
See similar questions with these tags.
plink
tool supports tunnels, or you can use a saved profile in PuTTY.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..?