Repository navigation
fix(sshd): serve connections concurrently with a login grace time - #3746
Merged
Merged
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 9 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
sshd.Serve handled one connection at a time and nothing limited how long a connection could take to log in, so a single client that connected and stayed silent blocked every other login.
Now Serve hands each accepted connection to a pool worker, up to the new
max_connections(default 64); connections over the cap are closed at once. ServeConnection starts a watchdog that shuts the socket if the handshake and authentication are not done within the newlogin_grace_ms(default 120000, 0 turns it off; also on ssh.ServerConfig). ServeOnce still serves one connection on the calling thread. sftpd gets the defaults but does not expose the two fields yet.Tested with a main-built compiler: new tests/en/stdlib/sshd_concurrent (an idle connection does not stop a second client from getting the banner, and is closed after the grace time), plus sftpd_basic, ssh_selftest, ssh_coverage, check on windows and darwin targets. By hand: with one idle nc open, ssh-keyscan answers in 0.1 s (main: no answer) and the idle socket closes after the grace time; with max_connections 2 the third connection is closed; three OpenSSH logins finish while a fourth session runs
sleep 4. sshd_basic is already red on main (client cannot negotiate ed25519) and ends the same way here, without hanging.This overlaps #3739 in
_ssh_configand the sshd docs. When both land, the host key from #3739 has to be carried through_Sharedinto_ssh_configin_serve_next; passing an empty key makes every connection refused, not hang.