I'm on Mac OS X 10.6.2 trying to connect to ubuntu server 8.04.1 at linode.
ssh -L 127.0.0.1:3306:[[remote ip]]:3306 user@server -N
I want to set up ssh tunneling so that I can access a remote mysql server.
First of all, I'm told bind: Address already in use
. This is only after I've tried the command before. How do I manually close a port forwarding session?
Second, when I change the command to be ssh -L 127.0.0.1:3310:[[remote ip]]:3306 user@server -N
(I changed the local port to listen on). I'm told channel 1: open failed: connect failed: Connection refused
when I try to connect to the MySQL server via MySQL workbench or sequel pro.
To connect through MySQL workbench I use the following settings:
- host: 127.0.0.1 port: 3310 (if 3306 is in use)
- username: mysql username
- password: mysql password
- database: I don't put anything in
This should work:
The first port number is the local port to use (must not be in use already), the IP in between the colons is the IP to connect to, from the perspective of the host you are sshing into. The second port number is the port to connect to. If you are connecting to a server other than the one you are sshing into, then try the following:
Usually, when I want to do this more than one time, I create an entry in ~/.ssh/config like the following where sshhost.example.com is the server I am sshing to, the local port I want to open is 5910, the IP on the other side I want to connect to is 192.168.35.69, and the port I want to connect to there is 5900:
Then from a command prompt I can just do
and get a tunnel to my desktop at the office.
Good luck,
--jed
Currently on Mac OS Catalina the
-N
argument is needed to avoid a regular login so the updated command would be: