Jan 26 2014
Accessing MYSQL server behind firewall using SSH
So, you want to access a MYSQL server but you only have an SSH terminal…
Not to worry, you can use SSH tunnelling to do this!
Basic Example
Example: ssh -L 3306:localhost:3306 user@IP -p SSHPORT
Now how do you control this dark ssh sorcery? Let’s break it down.
1) 3306:localhost:3306
- Open a port 3306 on my local machine to redirect
- localhost:3306 means we are tunnelling to 3306 on SSH machine
2) user@IP
This is your username and the IP address of the server
3) -p SSHPORT
This is the ssh port if it is not on 22.
Another Example
ssh -L 9000:192.168.212.1:5000 user@192.168.2.1 -p 1234
You would use this if you wanted to:
- use your computer port 9000
- to access the port 5000 on IP 192.168.212.1
- through the SSH server 192.168.2.1
- with SSH server port on 1234
Happy SSHing!
Recent Comments