如何从损坏的 xdebug 会话中恢复?

如何从损坏的 xdebug 会话中恢复?

有时,当我正在进行会话时,我的本地计算机会崩溃xdebug。当我使用反向 shell 重新连接到远程服务器时,我收到以下警告:

Warning: remote port forwarding failed for listen port 9000?

xdebug本地计算机崩溃后 如何立即从会话中恢复?

答案1

我不知道xdebug,但我认为这不相关。这只是一个 ssh 端口转发问题。问题是服务器上之前的 ssh 会话仍在运行,这意味着它仍然使用远程端口。

一种解决方案是终止以前的 ssh 会话。看看ps axukill

另一种解决方案是修改 sshd 配置,让服务器定期 ping 客户端,如果没有收到回复则终止会话。为此,您必须编辑/etc/ssh/sshd_config并设置ClientAliveInterval某些内容,例如,ClientAliveInterval 30这意味着如果未收到数据,服务器将在 30 秒后尝试到达客户端。

有关更多详细信息,我复制了相关部分man sshd_config

ClientAliveCountMax
        Sets the number of client alive messages (see below) which may be sent
        without sshd(8) receiving any messages back from the client. If this
        threshold is reached while client alive messages are being sent, sshd 
        will disconnect the client, terminating the session. It is important
        to note that the use of client alive messages is very different from
        TCPKeepAlive (below).  The client alive messages are sent through the 
        encrypted channel and therefore will not be spoofable. The TCP   
        keepalive option enabled by TCPKeepAlive is spoofable.  The client
        alive mechanism is valuable when the client or server depend on
        knowing when a connection has become inactive.

        The default value is 3.  If ClientAliveInterval (see below) is set to
        15, and ClientAliveCountMax is left at the default, unresponsive SSH
        clients will be disconnected after approximately 45 seconds.
        This option applies to protocol version 2 only.

ClientAliveInterval
        Sets a timeout interval in seconds after which if no data has been
        received from the client, sshd(8) will send a message through the
        encrypted channel to request a response from the client. The default
        is 0, indicating that these messages will not be sent to the client.
        This option applies to protocol version 2 only.

相关内容