I would like to connect to a remote MySQL from my host, but the host is behind a ssh proxy, like this.
I have 3 hosts in this problem
- A: my local machine (that can ssh to B)
- B: Intermediate machine that can SSH to C
- C: a remote server running MySQL and allows only connections from localhost (grant)
I use ~/.ssh/config to allow me to ssh directly from A to C (using B as proxy).
Host B ProtocolKeepAlives 30 HostName hostnameofB Host C ProtocolKeepAlives 30 ProxyCommand ssh -q B nc -q0 hostnameofC 22 LocalForward 3336 localhost:3306 Port 21343
I open a ssh from A to C with -vvv and see this:
debug1: Local connections to LOCALHOST:3336 forwarded to remote address localhost:3306
I then try to login to MySQL from A:
mysql -uMyUsername -pMyPassword DatabaseName -P3336 -h127.0.0.1 ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0
(if I try to use -hlocalhost it will try to log in to my local MySQL server, even if I use different ports)
in my SSH -vvv window I also see this:
client-session (t4 r0 i0/0 o0/0 fd 7/8 cc -1)
there is no logs on the C MySQL server.
any good suggestions?