LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Connection to MySQL through SSH tunnel (https://www.linuxquestions.org/questions/linux-server-73/connection-to-mysql-through-ssh-tunnel-4175554530/)

XDimensioN 09-25-2015 05:24 PM

Connection to MySQL through SSH tunnel
 
Hi

I tried to connect to MySQL through SSH tunnel by using JSCH library, but the procedure has failed. The MySQL server is installed in Ubuntu Server and the server machine is behind a D-Link router. I enabled debug logging of SSH server (auth.log) and this is how I got:

Code:

Sep 25 18:01:04 ubuntu-server sshd[13462]: debug1: SELinux support disabled
Sep 25 18:01:04 ubuntu-server sshd[13462]: debug1: PAM: establishing credentials
Sep 25 18:01:04 ubuntu-server sshd[13462]: debug1: permanently_set_uid: 1000/1000
Sep 25 18:01:04 ubuntu-server sshd[13462]: debug1: packet_set_postauth: called
Sep 25 18:01:04 ubuntu-server sshd[13462]: debug1: Entering interactive session for SSH2.
Sep 25 18:01:04 ubuntu-server sshd[13462]: debug1: server_init_dispatch_20
Sep 25 18:01:04 ubuntu-server sshd[13462]: debug1: server_input_channel_open: ctype direct-tcpip rchan 0 win 131072 max 16384
Sep 25 18:01:04 ubuntu-server sshd[13462]: debug1: server_request_direct_tcpip: originator 127.0.0.1 port 53656, target 127.0.0.1 port 3306
Sep 25 18:01:04 ubuntu-server sshd[13462]: debug1: connect_next: host 127.0.0.1 ([127.0.0.1]:3306) in progress, fd=17
Sep 25 18:01:04 ubuntu-server sshd[13462]: debug1: channel 0: new [direct-tcpip]
Sep 25 18:01:04 ubuntu-server sshd[13462]: debug1: server_input_channel_open: confirm direct-tcpip
Sep 25 18:01:04 ubuntu-server sshd[13462]: debug1: channel 0: connection failed: Connection refused
Sep 25 18:01:04 ubuntu-server sshd[13462]: debug1: channel 0: free: direct-tcpip, nchannels 1

I don't really know what is the cause of connection refuse. I even used tcpdump command to check if MySQL server receives the messages, this is what I got:

Code:

sudo tcpdump -i any 'port 3306' -v -XX
tcpdump: listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
18:20:19.744144 IP (tos 0x0, ttl 64, id 1650, offset 0, flags [DF], proto TCP (6), length 60)
    localhost.35978 > localhost.mysql: Flags [S], cksum 0xfe30 (incorrect -> 0x18aa), seq 1510133585, win 43690, options [mss 65495,sackOK,TS val 10144035 ecr 0,nop,wscale 6], length 0
        0x0000:  0000 0304 0006 0000 0000 0000 0000 0800  ................
        0x0010:  4500 003c 0672 4000 4006 3648 7f00 0001  E..<.r@.@.6H....
        0x0020:  7f00 0001 8c8a 0cea 5a02 cf51 0000 0000  ........Z..Q....
        0x0030:  a002 aaaa fe30 0000 0204 ffd7 0402 080a  .....0..........
        0x0040:  009a c923 0000 0000 0103 0306            ...#........
18:20:19.744199 IP (tos 0x0, ttl 64, id 2120, offset 0, flags [DF], proto TCP (6), length 40)
    localhost.mysql > localhost.35978: Flags [R.], cksum 0xef04 (correct), seq 0, ack 1510133586, win 0, length 0
        0x0000:  0000 0304 0006 0000 0000 0000 0000 0800  ................
        0x0010:  4500 0028 0848 4000 4006 3486 7f00 0001  E..(.H@.@.4.....
        0x0020:  7f00 0001 0cea 8c8a 0000 0000 5a02 cf52  ............Z..R
        0x0030:  5014 0000 ef04 0000                      P.......

Any suggestions is welcome. Thanks in advance.

Rinndalir 09-26-2015 02:55 PM

What is JSCH?

chrism01 09-27-2015 11:02 PM

Why not just use a std ssh tunnel eg http://blog.trackets.com/2014/05/17/...-examples.html


All times are GMT -5. The time now is 05:51 AM.