问题
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