通过IntelliJ IDEA中的两个ssh隧道连接到数据库 [英] Connect to database through two ssh tunnels in IntelliJ IDEA
问题描述
我正在尝试将PostgreSQL数据库添加为IntelliJ IDEA Ultimate中的数据源。
我已经通过ONE SSH隧道使用了数据源。但是现在数据库服务器位于防火墙之后,该防火墙仅接受来自管理服务器的ssh连接。访问数据库服务器的唯一方法是通过管理服务器。
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.
因此,我(或IntelliJ)必须通过ssh连接到该服务器,然后使用另一个用户通过ssh隧道连接到数据库服务器。
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.
一切都清楚吗? :-D
Everything clear? :-D
问题是IntelliJ仅提供配置一个ssh隧道的功能。但是在第一个隧道之后,我需要使用第二个隧道,最后才能连接到数据库服务器...
有什么想法吗?
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。
推荐答案
我会使用OpenSSH或任何类似的方法创建本地端口转发该工具将通过管理服务器将 127.0.0.1:2222
转发到 firewall:22
,然后使用IntelliJ IDEA隧道配置到 127.0.0.1:2222
就像使用单个隧道一样。
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<管理服务器>
您可以配置外部工具可自动执行此过程。在Windows计算机上,我在 Bitvise SSH客户端上具有丰富的经验,用于创建隧道/端口转发和自动启动它们。
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.
这篇关于通过IntelliJ IDEA中的两个ssh隧道连接到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!