Connect to database through two ssh tunnels in IntelliJ IDEA

百般思念 提交于 2019-12-11 10:25:00

问题


I'm trying to add a postgresql database as a datasource in IntelliJ IDEA Ultimate.
I've worked with a datasource through ONE ssh tunnel already. But now the database server is behind a firewall which only accepts ssh connections from a management server. The only way to access the db server goes over the management server.

So I (or IntelliJ) have to connect via ssh to this server and then, by using another user, tunnel via ssh to the database server.

Everything clear? :-D

The problem is, that IntelliJ offers only to configure one ssh tunnel. But after the first tunnel I need to use a second one, to finally connect to the database server... Any Ideas?

Thx in advance.


回答1:


I'd create a local port forward using OpenSSH or any similar tool which will forward 127.0.0.1:2222 to firewall:22 via the Management Server, then use IntelliJ IDEA tunnel configuration to 127.0.0.1:2222 like you would do with the single tunnel.

ssh -L 127.0.0.1:2222:firewall:22 <management server>

You can configure an External Tool to automate this process. On Windows machine I had great experience with Bitvise SSH Client for creating tunnels/port forwards and starting them automatically.



来源:https://stackoverflow.com/questions/54899619/connect-to-database-through-two-ssh-tunnels-in-intellij-idea

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!