问题
Apologies if this is in some way a duplicate - I couldn't find anything that covered this (at least in a way that I could understand made it similar).
Here's a basic diagram of my connections:
Laptop => SSH server 1 => SSH server 2 => MySQL (MariaDB)
I can use terminal to jump across to server 2 as per the usual methods:
ssh -t user@server1 ssh -p99 user@server2
Then, in the terminal, I can mysql -uroot -p
as normal.
(connections amended to remove details, of course)
I have attempted a few different things to try and get a direct connection in DBeaver, but I can't seem to make it work with that extra ssh connection (inssheption - it's new to me). I've found, and have been playing with, Gnome Connection Manager to try and make this happen - I'm used to Win tools like Penguinet, which isn't available on Linux, but it does look to be capable.
I'm probably just out of my depth, but I am thinking that this should be simple - but I just can't get the hang of how to get this going.
I'm expecting that at some point I'll be able to connect to 127.0.0.1:1234
in DBeaver (SQL GUI), but I'm just struggling to make that happen.
Does anyone have a moment to advise the best method to daisy-chain the connections together?
回答1:
Use port forwarding with SSH to bring remote port to your local machine.
ssh -L 1234:server1:1234 -t user@server1 ssh -L 1234:server2:1234 -p99 user@server2
Now you can connect to localhost:1234
and your connection will be forwarded to server2:1234. Just make sure that port 1234 on server1 and localhost are not in use.
来源:https://stackoverflow.com/questions/45195422/mysql-connection-in-gui-via-two-ssh-connections-on-mint