前台的ssh隧道适用于mysql主机localhost和127.0.0.1,但后台的ssh-tunnel不起作用

时间:2018-06-21 00:02:14

标签: mysql ssh ssh-tunnel

因此,这与我之前的问题类似,除了现在127.0.0.1也不起作用:ssh tunnel in foreground works for mysql host localhost but ssh-tunnel in background works for mysql host 127.0.0.1

debug1: Authentication succeeded (publickey).
Authenticated to machine-two-hostname.com ([###.##.##.##]:22).
debug1: Local connections to LOCALHOST:3360 forwarded to remote address localhost:3360
debug3: channel_setup_fwd_listener_tcpip: type 2 wildcard 0 addr NULL
debug3: sock_set_v6only: set socket 4 IPV6_V6ONLY
debug1: Local forwarding listening on ::1 port 3360.
debug2: fd 4 setting O_NONBLOCK
debug3: fd 4 is O_NONBLOCK
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on 127.0.0.1 port 3360.
debug2: fd 5 setting O_NONBLOCK
debug3: fd 5 is O_NONBLOCK
debug1: channel 1: new [port listener]
debug2: fd 3 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IP_TOS 0x10
debug1: Requesting no-more-sessions@openssh.com
debug3: send packet: type 80
debug1: forking to background
debug1: Entering interactive session.
debug1: pledge: network
debug3: receive packet: type 80
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0

我偶尔会做“ keepalive”,这很正常:

debug1: client_input_global_request: rtype keepalive@openssh.com want_reply 1
debug3: send packet: type 82
debug3: receive packet: type 80
debug1: client_input_global_request: rtype keepalive@openssh.com want_reply 1
debug3: send packet: type 82

我运行的命令是:

ssh -vvvvv -fN -L 3360:localhost:3360 admin@machine-two-hostname.com

通过后台ssh隧道的所有连接均被拒绝,但我可以通过前台ssh进行良好连接:

$ mysql -uroot -proot -h127.0.0.1
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111 "Connection refused")

更新:我正在使用mysql-client这个答案可能与以下内容有关: MYSQL ERROR 2003 (HY000) (113) in SSH remote tunneling, but telnet from SSH tunnel works

1 个答案:

答案 0 :(得分:0)

我正在使用3360端口,MySQL在3306端口上。