SCP 有效,但 SSH 无效(通过 wifi)

Dav*_*ave 4 linux wifi ssh scp

当我在办公室使用 wifi 时,我可以使用 SCP 将文件复制到我的服务器和从我的服务器复制文件,但由于某种原因 SSH 没有响应。它只是挂起,不打印任何东西,我无法ctrl-c结束它;我必须关闭终端窗口。

当我插入 LAN 时,一切正常。任何想法如何弄清楚发生了什么?

Dav*_*ave 5

我终于找到了导致问题的原因。这是由于我的路由器在我无线连接时阻止了 TCP 保持连接消息(见图)。

ssh my_server -o TCPKeepAlive=no解决了我所有的问题。好极了!

从文档:

TCPKeepAlive
  Specifies whether the system should send TCP keepalive messages
  to the other side. If they are sent, death of the connection or
  crash of one of the machines will be properly noticed.  However,
  this means that connections will die if the route is down tem-
  porarily, and some people find it annoying.  On the other hand,
  if TCP keepalives are not sent, sessions may hang indefinitely on
  the server, leaving "ghost" users and consuming server resources.

  The default is "yes" (to send TCP keepalive messages), and the
  server will notice if the network goes down or the client host
  crashes.  This avoids infinitely hanging sessions.

  To disable TCP keepalive messages, the value should be set to
  "no".
Run Code Online (Sandbox Code Playgroud)