Double tunneling using HeidiSQL

[expired user #8346]'s profile image [expired user #8346] posted 10 years ago in General Permalink
Hi,

how can I configure following scenario or is it even possible.

I have server x and y. I can access to server y only via server x.

I have HeidiSQL and plink.exe to use
jfalch's profile image jfalch posted 9 years ago Permalink
AFAIK this can not be done directly. You could use

plink.exe -L 3307:host1:3307 -m cmds.sh -pw passwd1 user1@host1

where the file cmds.sh contains the single command

ssh -N -L 3307:host2:3306 user2@host2

to set up the secondary tunnel to host2.

however, this can not be automatically called from heidisql since it gives no means to modify the generated plink.exe call; you have to call this by hand before opening the appropriate session (which should NOT specify type "SSH tunnel", but just use type "MySQL (TCP/IP)" with host =localhost and port =3307).
also, the second password must be input by hand, since ssh does not have an equivalent of the -pw switch. you could also use publickey auth on the secondary host if posssible, this would then use the -i keyfile switch with ssh.
[expired user #8346]'s profile image [expired user #8346] posted 9 years ago Permalink
Should this "cmds.sh" locate on my local computer on host1? I'm using windows 7 so if it's local file should it be in .bat or what?
jfalch's profile image jfalch posted 9 years ago Permalink
cmds.sh has to be on your local computer, and you have to specify it with path to plink.exe -L.. -m x:\path\to\cmds.sh ..
You can put it where you want. It is not exactly a .bat file, but a unix bash command.
[expired user #8346]'s profile image [expired user #8346] posted 9 years ago Permalink
ok, got this finally working. cmds.sh should contain following: "ssh -fNg -L 3307:127.0.0.1:3306 user@host2"
I have the ssh key between host1 host2

And I have edited plink.exe shortcut parameters:
"C:\Users\xxx\Desktop\xxx\ssh key\plink.exe" -L 3307:host1:3307 -pw passwor user@host1 bash -x "/user/cmds.sh"

hope this helps also others.

Please login to leave a reply, or register at first.