1

我正在尝试使用 Sequel Pro 通过 SSH 连接到 DigitalOcean SSD 上的远程 MySQL 数据库。这是我的设置:


  • 名称:MyWebApp
  • MySQL-主机:188.226.150.240
  • 用户:本地主机
  • 密码:mySQLpassword
  • 数据库:轨道
  • 端口:3306

  • SSH 主机:mywebapp.com
  • SSH用户:root
  • SSH 密钥:~/.ssh/id_rsa
  • SSH 端口:22

尝试连接时,我得到:

SSH 端口转发失败。

在“读取初始通信数据包”时失去与 MySQL 服务器的连接,系统错误:0


Used command:  /usr/bin/ssh -v -N -o ControlMaster=no -o ExitOnForwardFailure=yes -o ConnectTimeout=10 -o NumberOfPasswordPrompts=3 -i /Users/tintin/.ssh/id_rsa -o TCPKeepAlive=no -o ServerAliveInterval=60 -o ServerAliveCountMax=1 -p 22 root@mywebapp.com -L 61232/188.226.150.240/3306

OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to mywebapp.com [188.226.150.240] port 22.
debug1: fd 3 clearing O_NONBLOCK
debug1: Connection established.
debug1: identity file /Users/tintin/.ssh/id_rsa type 1
debug1: identity file /Users/tintin/.ssh/id_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.0p1 Debian-3ubuntu1.2
debug1: match: OpenSSH_6.0p1 Debian-3ubuntu1.2 pat OpenSSH*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 42:f3:30:1b:ff:24:92:17:62:19:13:03:e9:65:0d:42
debug1: Host 'mywebapp.com' is known and matches the RSA host key.
debug1: Found key in /Users/tintin/.ssh/known_hosts:4
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/tintin/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to mywebapp.com ([188.226.150.240]:22).
debug1: Local connections to LOCALHOST:61482 forwarded to remote address 188.226.150.240:3306
debug1: Local forwarding listening on ::1 port 61482.
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on 127.0.0.1 port 61482.
debug1: channel 1: new [port listener]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Connection to port 61482 forwarding to 188.226.150.240 port 3306 requested.
debug1: channel 2: new [direct-tcpip]
channel 2: open failed: connect failed: Connection refused
debug1: channel 2: free: direct-tcpip: listening port 61482 for 188.226.150.240 port 3306, connect from 127.0.0.1 port 61484, nchannels 3

(我尽可能用虚假数据替换了我的 IP 地址、用户名和应用程序名称。)

我已经多次通过 SSH 登录到我的服务器,所以我不明白为什么它也不能与 Sequel Pro 一起使用。

我在这里想念什么?

谢谢你的帮助。

4

1 回答 1

1
debug1: Connection to port 61482 forwarding to 188.226.150.240 port 3306 requested.
debug1: channel 2: new [direct-tcpip]
channel 2: open failed: connect failed: Connection refused

这表明 mywebapp.com 上的 ssh 服务器实例尝试连接到 188.226.150.240 端口 3306 以服务端口转发,并收到“连接被拒绝”错误。

“连接被拒绝”通常意味着没有任何东西正在侦听该地址和端口上的连接。最简单的解释是 mysql 服务器没有运行,或者它正在侦听与您尝试连接的接口和/或端口不同的接口和/或端口。

您应该登录 188.226.150.240 并使用“netstat”查看是否有任何东西在侦听端口 3306。您可能会发现 msyql 没有运行,或者它只是在侦听 localhost 接口,或者类似的东西。

或者,可以将防火墙等网络设备设置为在决定阻止连接时模拟“连接被拒绝”的情况。如果 ssh 服务器和 mysql 服务器之间的网络流量通过防火墙,您可以调查它是否由于某种原因阻止了流量。

于 2015-05-13T15:28:20.067 回答