I need to access a MySQL database on a remote server at my lab. The server is only accessible once I log in to a gateway server on the remote network:
local serv
If You need to use multiple hops to access MySQL server I first recommend to create .ssh/config file and use ProxyCommand like so:
Host gateway
HostName example.com
User foo
Port 22
IdentityFile ~/.ssh/id_rsa.pub
Host mysql_access_server
HostName example-web.com
Port 22
User foo
ProxyCommand ssh -A gateway nc %h %p
Then forward port like so:
ssh -f mysql_access_server -L 3309:sqlmaster.example.com:3306 -N
Then You can access MySQL server like so:
mysql --user=root --host=127.0.0.1 --password=root --port=3309 some_db_name