mysql tunnel

followed instructions here

http://library.linode.com/databases/mys … ssh-tunnel">http://library.linode.com/databases/mysql/mysql-ssh-tunnel

When I start the script I get

ssh: connect to host domain.com port 22:Connection refused

since I am not using port 22 to ssh, the tunnel script gives me error. How can I fix this? Where and how can I add the port number I am using to the script?

I tried

$remote_host = "domain.com:2222";

that didnt work.

??

thank you

11 Replies

Change

system "ssh -f -L $localip:$localport:$remoteip:$remoteport $remoteuser\@$remotehost -N";

to system "ssh -p -f -L $localip:$localport:$remoteip:$remoteport $remoteuser\@$remotehost -N";

(Why'd you change the default ssh port, btw? It doesn't make you any more insecure. Infact, making it port >1024 makes you slightly less secure)

thank you. It did help. It connects.

However, I cant access it on localhost:3306, I wonder what I am missing.

When I go to localhost:3306 on the browser, on the terminal I get "channel 1: open failed: connect failed: Connection refused"

any ideas how I can resolve this issue ???

I am using a different port number, in order to make it more secure. I am not using 1024. I wonder why 1024 is less secure compare to other ports.

thank you.

@superdupler:

I wonder why 1024 is less secure compare to other ports.
Not just 1024, any port greater than 1024. Ports below 1024 require root privileges to access them, so are more difficult to screw around with.

@superdupler:

When I go to localhost:3306 on the browser, on the terminal I get "channel 1: open failed: connect failed: Connection refused"
Sound like you might still need to configure MySQL to listen on localhost. In the [mysqld] section of /etc/mysql/my.cnf, comment out the 'skip-networking' line and add a line that says bind-address = 127.0.0.1

I already have that….

cd /etc/mysql/my.cnf

bind-address = 127.0.01

Moving ssh from port 22 is just another layer in the security onion. Also, bots won't be able to try any zero day vulns on the ssh daemon (remember what happened to Debian).

I reinstall mysql server on the local computer. Then, I installed mysql query browser, and mysql administrator.

I checked my local mysql on the firefox browser localhost:3306. The browser stated "Got Packets out of order". In any case, I launched mysql query browser. I was able to see the database, and tables without a problem.

Then, I used the mysql-tunnel.pl from the instructions.

On the terminal I got a message.
> bind: Address already in use

channelsetupfwd_listener: cannot listen to port: 3306

Could not request local forwarding.

Then, I tried again by changing the $localport = "3306"; to $localport = "3307"; on mysql-tunnel.pl. Then, I got

> channel 1: open failed: connect failed: Connection refused

???

@superdupler:

On the terminal I got a message.
> bind: Address already in use

channelsetupfwd_listener: cannot listen to port: 3306

Could not request local forwarding.
You have something already running. Kill it first.

on mysql query browser I get this error.

> Could not connect to host '127.0.0.1'.

MySQL Error Nr. 2013

Lost connection to MySQL server at 'reading initial communication packet', system error:0

Click the 'Ping' button to see if there is a networking problem

on the terminal
> channel 1: open failed: connect failed: Connection refused

???

I have been trying to set this Mysql Administrator - query browser without any luck.

On my remote server, the my.cnf bind address isnt 127.0.0.1, nor localhost. It is a local network address (192.168.166.9)

So, I decided to change my.cnf on my local computer bind address from 127.0.0.1 to the same local network address of the remote server. 192.168.166.9

then I did

ssh -p 2222 -v -f -N -L 3307:192.168.166.9:3306 user@serverip

Then, try to use mysql query browser, I get similar errors

MySQL Error Nr. 2003

I think my iptables are set correct.

I even tried to connect by using the connections here. I get the same errors.

http://www.debuntu.org/port-forwarding- … on-refused">http://www.debuntu.org/port-forwarding-and-channel-3-open-failed-connect-failed-Connection-refused

how can I solve this issue?

on the local computer /etc/mysql/my.cnf

changed bind address=0.0.0.0

some progress, but still get errors.

on the query browser…
> Could not connect to host '127.0.0.1'.

MySQL Error Nr. 1130

Host '192.168.166.9' is not allowed to connect to this MySQL server

on the terminal
> Connection to port 3307 forwarding to 192.168.166.9 port 3306 requested.

debug1: channel 2: new [direct-tcpip]

debug1: Connection to port 3307 forwarding to 192.168.166.9 port 3306 requested.

debug1: channel 3: new [direct-tcpip]

debug1: channel 2: free: direct-tcpip: listening port 3307 for 192.168.166.9 port 3306, connect from 127.0.0.1 port 58429, nchannels 4

debug1: channel 3: free: direct-tcpip: listening port 3307 for 192.168.166.9 port 3306, connect from 127.0.0.1 port 58430, nchannels 3

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct