From nobody Wed Mar 1 13:03:27 2023 X-Original-To: freebsd-net@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PRZDN2JxJz3tr03 for ; Wed, 1 Mar 2023 13:03:32 +0000 (UTC) (envelope-from mike@karels.net) Received: from mail2.karels.net (mail2.karels.net [3.19.118.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "freebsd", Issuer "freebsd" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PRZDN0b6jz4lG9; Wed, 1 Mar 2023 13:03:32 +0000 (UTC) (envelope-from mike@karels.net) Authentication-Results: mx1.freebsd.org; none Received: from mail2.karels.net (localhost [IPv6:0:0:0:0:0:0:0:1]) by mail2.karels.net (8.16.1/8.16.1) with ESMTP id 321D3Ru4088668; Wed, 1 Mar 2023 07:03:28 -0600 (CST) (envelope-from mike@karels.net) Received: from [10.0.2.130] ([73.62.165.147]) by mail2.karels.net with ESMTPSA id +YPSOR9N/2NaWgEAs/W3XQ (envelope-from ); Wed, 01 Mar 2023 07:03:28 -0600 From: Mike Karels To: Michael Gmelin Cc: Yuri , freebsd-net@freebsd.org Subject: Re: sshd doesn't disconnect for 30+ minutes after the TCP connection is closed ungracefully Date: Wed, 01 Mar 2023 07:03:27 -0600 X-Mailer: MailMate (1.14r5937) Message-ID: <49CE5046-7934-414C-9B62-F3712DECBA52@karels.net> In-Reply-To: <08DDB90C-5D30-40A3-86C0-87021959F04D@freebsd.org> References: <08DDB90C-5D30-40A3-86C0-87021959F04D@freebsd.org> List-Id: Networking and TCP/IP with FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-net List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-net@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 4PRZDN0b6jz4lG9 X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:16509, ipnet:3.16.0.0/14, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N On 1 Mar 2023, at 5:36, Michael Gmelin wrote: >> On 1. Mar 2023, at 11:35, Yuri wrote: >> >> =EF=BB=BFWindows system connects to FreeBSD through ssh and then this = connection dies because of WiFi or VPN issues. >> >> FreeBSD still has the sshd process alive for this connection for 30+ m= inutes. >> >> TCP keepalive is enabled on the FreeBSD host: >> >> $ sysctl net.inet.tcp.always_keepalive >> net.inet.tcp.always_keepalive: 1 >> >> Shouldn't TCP keepalive kill this sshd process after 3-4 minutes becau= se this connection isn't alive? >> > > Keepalives start after net.inet.tcp.keepidle milliseconds (2h by defaul= t). When this happens to me, I generally log into the server again and use wr= ite(1) to send a message to that tty (a newline will do). That probes the conne= ction and causes a reset, and the session gets cleaned up. I use a longer keep= idle value for other reasons. Mike