diff --git a/ocaml/xapi/xapi_periodic_scheduler_init.ml b/ocaml/xapi/xapi_periodic_scheduler_init.ml index ff7c3187c20..e238e9daa62 100644 --- a/ocaml/xapi/xapi_periodic_scheduler_init.ml +++ b/ocaml/xapi/xapi_periodic_scheduler_init.ml @@ -91,9 +91,14 @@ let register ~__context = let remaining = Int64.sub expiry_time current_time in Xapi_host.schedule_disable_ssh_job ~__context ~self ~timeout:remaining ~auto_mode:true - (* handle the case where XAPI is not active when the SSH timeout expires *) - else if Fe_systemctl.is_active ~service:!Xapi_globs.ssh_service then - Xapi_host.disable_ssh ~__context ~self + (* Handle the case where XAPI is not active when the SSH timeout expires. + This typically occurs when XAPI has been down for an extended period that + exceeds the timeout duration. In this scenario, we need to enable SSH auto + mode to ensure the SSH service remains continuously available. *) + else if Fe_systemctl.is_active ~service:!Xapi_globs.ssh_service then ( + Xapi_host.disable_ssh ~__context ~self ; + Xapi_host.set_ssh_auto_mode ~__context ~self ~value:true + ) in let update_all_subjects_delay = 10.0 in (* initial delay = 10 seconds *)