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
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.