Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect using SSH tunnel #66

Closed
sosedoff opened this issue Nov 21, 2014 · 4 comments
Closed

Connect using SSH tunnel #66

sosedoff opened this issue Nov 21, 2014 · 4 comments

Comments

@sosedoff
Copy link
Owner

Everything works fine until you want to connect to a postgres server that sits behind firewall.

The only option in this case is to use ssh tunnels. In order to make it work, user has to use ssh to establish connection with a remote machine. Example:

ssh -Ng -L 5433:localhost:5432 user@remotehost.com

This should work on linux and osx but not on windows, which does not have a standard ssh
binary available. I've been digging around to find any good and stable example on how to run
ssh tunnel programmatically with Go. No luck yet.

Having ability to connect to a behind-firewall postgres instance is very useful and i tend to just go ahead
and implement "experimental" support for this feature using good old exec.Command that'll spawn ssh
and establish a tunnel. I have already tried this solution and it works great (except when internet connection is shitty), client code that communicates with postgres server does not have to be changed at all. But it makes pgweb environment-dependent, which is not great.

Would like to get some feedback or even examples on how to get this feature done.

@cbandy @pvh any thoughts?

@cbandy
Copy link
Contributor

cbandy commented Nov 21, 2014

Can't someone who knows how to tunnel just set it up before running pgweb? I think it is normal to setup a tunnel or SOCKS proxy separately from a client. Do other pg clients make this easy?

  1. We could write the feature to support ssh only.
  2. We could allow the user could configure any executable to build the tunnel. It should print host:port or host port when ready.

I've only used Putty on Windows, and it was a long time ago. It supported SOCKS, at least.

@pvh
Copy link
Contributor

pvh commented Dec 5, 2014

Back when I was a Windows user there was a pretty standard tool for solving
this problem that most people used to create ssh tunnels. I wish I could
remember what it was called. Maybe I used to use Putty for that? Could be.

I agree with Chris' assessment which is that merging this functionality
into pgweb would be weird. Maybe not full-on wrong, but not really high on
the list of things I'd expect such a system to do. I'd probably start with
a documentation fix and go from there, particularly since each platform
will be different and probably get more different over time.

-p

On Fri, Nov 21, 2014 at 12:59 AM, Chris Bandy notifications@github.com
wrote:

Can't someone who knows how to tunnel just set it up before running pgweb?
I think it is normal to setup a tunnel or SOCKS proxy separately from a
client. Do other pg clients make this easy?

  1. We could write the feature to support ssh only.
  2. We could allow the user could configure any executable to build the
    tunnel. It should print host:port or host port when ready.

I've only used Putty on Windows, and it was a long time ago. It supported
SOCKS, at least.


Reply to this email directly or view it on GitHub
#66 (comment).

@sosedoff
Copy link
Owner Author

sosedoff commented Dec 5, 2014

Yeah, i posted instructions on how to connect via ssh gateway. But the reason why i want to merge this functionality into pgweb is to simplify usage. Go has ssh support so it just makes sense to implement native support.

@sosedoff
Copy link
Owner Author

Closing this issue for now. SSH support might be added some day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants