- 
                Notifications
    You must be signed in to change notification settings 
- Fork 3k
ssh: ssh keep alive #9125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
ssh: ssh keep alive #9125
Conversation
| CT Test Results    2 files     29 suites   19m 45s ⏱️ For more details on these failures, see this check. Results for commit 8814976. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts
 // Erlang/OTP Github Action Bot | 
| @u3s this a feature I promised long time ago, if you are still interested in it please continue reading :) I know you are short on time, but if you could give me some tips on how to create some tests for this would be appreciated. I wanted to add tests at least these 3 scenarios: 
 | 
62ef27e    to
    5b99b40      
    Compare
  
    | 
 | 
| Sounds good. I’ll rebase and start working on the tests. | 
5b99b40    to
    aac13e4      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds client/server keep-alive support by introducing interval/count parameters and integrating timers into the SSH finite-state machines.
- Defines a new alive_paramsoption with default count/interval and validation
- Schedules and handles keep-alive and renegotiation timeout events in userauth and key exchange FSMs
- Implements keep-alive macros, timer logic, and record fields in the connection handler
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description | 
|---|---|
| ssh_options.erl | Added alive_paramsoption with default and check logic | 
| ssh_fsm_userauth_server.erl | Switched idle timeout to start_alivefor keep-alive | 
| ssh_fsm_userauth_client.erl | Scheduled initial keep-alive timer on auth success | 
| ssh_fsm_kexinit.erl | Added renegotiation alive timer after new keys | 
| ssh_connection_handler.erl | Introduced macros and functions for keep-alive handling | 
| ssh.hrl | Extended #ssh{}record with keep-alive fields | 
Comments suppressed due to low confidence (3)
lib/ssh/src/ssh_connection_handler.erl:2191
- No unit tests were added for the new keep-alive timeout logic. Consider covering get_next_alive_timeout,triggered_alive, andreset_alivewith targeted tests.
get_next_alive_timeout(#ssh{alive_interval = AliveInterval,
lib/ssh/src/ssh.hrl:1285
- [nitpick] The alive_startedfield is added but never referenced in the code. Either remove it or implement logic to set and check this flag.
          alive_started = false               :: boolean(),
lib/ssh/src/ssh_connection_handler.erl:100
- [nitpick] The global request name is given as a list; consider using a binary (e.g., <<"[email protected]">>) to match typical SSH message encoding.
    {ssh_msg_global_request,"[email protected]", true,<<>>}).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please check inline comments.
Copilot repeated some of my observations.
we would need some docs and tests.
7825483    to
    c456cc4      
    Compare
  
    | @u3s I have just pushed changes that address most of the comments. There's 2 tests now in place. I started to add a third test that checks that the renegotiation_alive timeout works, but I could not start the renegotiation. I left a comment on the test and mentioned you there to see if you can try to help spot what am I doing wrong. | 
4339a10    to
    4046e53      
    Compare
  
    3d92154    to
    fa6105b      
    Compare
  
    2102453    to
    b0a6554      
    Compare
  
    - use alive in ssh_to_openssh_SUITE for Erlang implementation - drop alive_awaiting_response flag - don't process ssh_msg_request_success and ssh_msg_request_failure outside of ssh_connectio module
This PR aims at introducing the equivalent of openssh ClientAliveInterval/ClientAliveCountMax (https://man.openbsd.org/sshd_config#ClientAliveCountMax) and ServerAliveInterval/ServerAliveCountMax
There's 2 notable differences: