2
2
Three machines are involved here.
- Localhost where I do my development. AKA laptop.
- Bastion host where you must connect first. AKA jump.
- MySQL server where I want to connect to. AKA DB.
My ssh public key is in /home/myusername/.ssh/authorized_keys on jump.
My ~/.ssh/config has this:
Host jump
HostName jump.domain.com
User myusername
IdentityFile ~/.ssh/myprivatekey
I can ssh jump
and get onto jump fine.
What ssh command do I need to run in terminal on Laptop in order to be able to connect from Laptop to DB via
mysql -h 127.0.0.1 -P 3308
I need an SSH tunnel and a port forwarding, but I have yet to get the syntax correct. I want to use 3308 for production DB and 3307 for staging DB and am running local MySQL DB on 3306, which is why port forwarding to non-standard mysql ports.
Do you have extra sources to corroborate your response? It looks a little too simple to be that easy a retort to this question. I'm not calling you "wrong". I'm just skeptical. – killermist – 2015-01-24T01:46:32.223
I am pretty sure -t (force pseudo-tty) is not required for a tunnel to a MySQL server, and -f is required to run a remote command. – phpguru – 2015-01-28T17:41:41.383