Adriana Rodean
2010-Jul-01 06:47 UTC
ssh server hangs the port even if client machine shuts down
Hi, I have the following problem with ssh, hope someone can help me with it: I have 2 processes of ssh server on same Linux machine. One of them is the normal ssh configuration for Linux, the other one starts with a custom configuration on another port.>From the client i do a remote port forwarding to the custom sshserver: ssh -R 1037:localhost:55555. After this command on ssh server process list i see: sshd 29996 root 3r IPv4 1310919488 TCP 10.55.41.92:2233->10.55.40.121:2481 (ESTABLISHED) sshd 30000 615da7706d6c4babbcd6e6fb867ddab1 3u IPv4 1310919488 TCP 10.55.41.92:2233->10.55.40.121:2481 (ESTABLISHED) sshd 30000 615da7706d6c4babbcd6e6fb867ddab1 7u IPv4 1310919539 TCP 127.0.0.1:1037 (LISTEN) sshd 30000 615da7706d6c4babbcd6e6fb867ddab1 8u IPv6 1310919540 TCP [::1]:1037 (LISTEN) sshd 30000 615da7706d6c4babbcd6e6fb867ddab1 9u IPv4 1310919596 TCP 127.0.0.1:48818->127.0.0.1:http-alt (ESTABLISHED) Then after awhile: sshd 29996 root 3r IPv4 1310919488 TCP 10.55.41.92:2233->10.55.40.121:2481 (ESTABLISHED) sshd 30000 615da7706d6c4babbcd6e6fb867ddab1 3u IPv4 1310919488 TCP 10.55.41.92:2233->10.55.40.121:2481 (ESTABLISHED) sshd 30000 615da7706d6c4babbcd6e6fb867ddab1 7u IPv4 1310919539 TCP 127.0.0.1:1037 (LISTEN) sshd 30000 615da7706d6c4babbcd6e6fb867ddab1 8u IPv6 1310919540 TCP [::1]:1037 (LISTEN) sshd 30000 615da7706d6c4babbcd6e6fb867ddab1 9u IPv4 1310919596 TCP 127.0.0.1:48818->127.0.0.1:http-alt (CLOSE_WAIT) Then after awhile: sshd 29996 root 3r IPv4 1310919488 TCP 10.55.41.92:2233->10.55.40.121:2481 (ESTABLISHED) sshd 30000 615da7706d6c4babbcd6e6fb867ddab1 3u IPv4 1310919488 TCP 10.55.41.92:2233->10.55.40.121:2481 (ESTABLISHED) sshd 30000 615da7706d6c4babbcd6e6fb867ddab1 7u IPv4 1310919539 TCP 127.0.0.1:1037 (LISTEN) sshd 30000 615da7706d6c4babbcd6e6fb867ddab1 8u IPv6 1310919540 TCP [::1]:1037 (LISTEN) When client shuts down computer, i noticed that the 1037 port is still listening on the server, but its PID changed. So even when the client computer is completely shut down => no connection with the ssh server, on the ssh server i have: sshd 32025 root 3r IPv4 1310943105 TCP 10.55.41.92:2233->10.55.40.121:2485 (ESTABLISHED) sshd 32029 615da7706d6c4babbcd6e6fb867ddab1 3u IPv4 1310943105 TCP 10.55.41.92:2233->10.55.40.121:2485 (ESTABLISHED) sshd 32029 615da7706d6c4babbcd6e6fb867ddab1 7u IPv4 1310943156 TCP 127.0.0.1:1037 (LISTEN) sshd 32029 615da7706d6c4babbcd6e6fb867ddab1 8u IPv6 1310943157 TCP [::1]:1037 (LISTEN) Problem is when client opens computer again (after shut down/restart) it isn't able to connect with same command: ssh -R 1037:localhost:55555 because that port is still listening on the server :( It takes long time to be able to connect again to server, sometimes even 2 hours :( Why the port still listens on the server even if no client is connected to it? (client pc is closed) How can we solve this problem? I want that process with the client port to be closed when client shuts down PC, so client after restart be able to reconnect with same command when PC is up again... Thank you, Adriana
Peter Stuge
2010-Jul-01 11:26 UTC
ssh server hangs the port even if client machine shuts down
Adriana Rodean wrote:> Why the port still listens on the server even if no client is > connected to it? (client pc is closed)Because TCP by design does not know if the other side of the connection has disappeared when there is no traffic, and SSH does not mandate probing for it. In short, the sshd on the server still believes that the client is connected.> How can we solve this problem?Please read the sshd_config manual page, in particular the ClientAliveCountMax and ClientAliveInterval options. //Peter
Adriana Rodean
2010-Jul-02 06:05 UTC
ssh server hangs the port even if client machine shuts down
Thank you so much :) Fixed the problem with: ClientAliveInterval 5 ClientAliveCountMax 2 :) On Thu, Jul 1, 2010 at 14:26, Peter Stuge <peter at stuge.se> wrote:> Adriana Rodean wrote: >> Why the port still listens on the server even if no client is >> connected to it? (client pc is closed) > > Because TCP by design does not know if the other side of the > connection has disappeared when there is no traffic, and SSH > does not mandate probing for it. > > In short, the sshd on the server still believes that the client is > connected. > > >> How can we solve this problem? > > Please read the sshd_config manual page, in particular the > ClientAliveCountMax and ClientAliveInterval options. > > > //Peter > _______________________________________________ > openssh-unix-dev mailing list > openssh-unix-dev at mindrot.org > https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev >