【问题标题】:How do I resolve SSH connections failing?如何解决 SSH 连接失败的问题?
【发布时间】:2013-10-07 13:38:41
【问题描述】:

我在 Mac 上使用 MySqlWorkbench,并使用 SSH 连接到多个远程服务器。

其中 2 个是本地的 - 一个在我的本地 VM 中,一个在房间对面的服务器上。第三个是世界范围内的其他地方。

我可以愉快地打开工作台并立即连接到我的 2 台本地服务器。

我可以打开工作台几个小时什么都不做,然后连接到它们,一切仍然有效。

我可以打开工作台并立即连接到远程服务器。一切都很好。

但是,如果我尝试在任何延迟(比如一个小时左右)后连接到真正的远程服务器,我会收到错误消息。

Your connection attempt failed for user 'root' from your host to server at 127.0.0.1:3306:
Tunnel error: Remote connection to 127.0.0.1:3306 failed: IOError('open SSH channel timeout',)

Please:
1 Check that mysql is running on server 127.0.0.1
2 Check that mysql is running on port 3306 (note: 3306 is the default, but this can be changed)
3 Check the root has rights to connect to 127.0.0.1 from your address (mysql rights define what clients can connect to the server and from which machines) 
4 Make sure you are both providing a password if needed and using the correct password for 127.0.0.1 connecting from the host address you're connecting from

此时,我关闭应用程序,重新打开它,建立连接,一切都很好。

但是非常令人沮丧的是不得不等待 30 秒左右才能意识到我将无法获得连接,然后不得不关闭应用程序然后重新打开它。

应用程序有时会崩溃,但不够频繁。

关于我可以做些什么来帮助识别和消除问题的任何建议?

问候,

理查德。

【问题讨论】:

  • 不是超时解决方案,而是为了更方便的重新连接,请使用菜单 -> 查询 -> 重新连接到服务器。

标签: mysql macos ssh mysql-workbench


【解决方案1】:

如果我正确理解了这个场景,那么如果连接空闲一段时间,你就会遇到连接挂掉的问题。尝试设置 keepalive 选项以每隔几秒钟继续生成一些数据包。这应该可以防止您的连接中断。

如果您自己设置连接,请将-o TCPKeepAlive=yes 添加到命令行。如果是某个应用程序为您启动连接,则设置:

Host *
TCPKeepAlive yes

在您的~/.ssh/config 中应该可以解决问题。

【讨论】:

    猜你喜欢
    • 2019-07-07
    • 1970-01-01
    • 2011-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-07
    • 2020-09-28
    • 2017-01-03
    相关资源
    最近更新 更多