Currently there is no way for the sftp backend (sftp-server or internal-sftp) to close idle connections (by idle I mean no order sent for some time by the sftp client). This is very problematic for SFTP servers because clients can remain connected, which consumes file descriptors and resources in general, causing potentially system limits to be reached. This is a case I handled recently, where system-wide file descriptors were exhausted, due to left-opened sftp sessions + corresponding systemd sessions. There are "ClientAlive*" properties but these only work for dead clients. So far, the only solution I found is to have a script that runs regularly and checks if /proc/<sftpserver>/fd/0 access time is older than a certain timestamp, and kill the PID accordingly. See also Red Hat Bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=2135811.
Created attachment 3618 [details] Proposed implementation using new "-t <sesion_timeout>" option to sftp-server Tested with: - no parameter (no timeout) - "-t 0" (no timeout) - "-t 30" (30 seconds timeout)
See also https://github.com/openssh/openssh-portable/pull/350
+1 for this. Indeed a very good proposal.
I don't want to do this in sftp-server. See https://github.com/djmdjm/openssh-wip/pull/16 for a more general mechanism
The more general mechanism shipped in OpenSSH 9.2
OpenSSH 9.3 has been released. Close resolved bugs