Change ssh session idle time-out on Azure VMs

Michela Toscano 6 Reputation points
2022-11-17T01:03:43.377+00:00

Hello!

It appears that there is some sort of ssh session time-out set in Azure VMs, where sessions are terminated after what appears to be less than 10 minutes of idle time (this is a rough estimate -- I haven't timed it, specifically).

How can this idle timeout be changed, if that is indeed the cause of this issue?

I checked the sshd configuration parameters in Linux, and they do not appear to be set in such a way that would cause idle ssh sessions to be terminated so soon.

I tried setting the sshd session idle time-out parameters as follows, to no avail:

ClientAliveCountMax 0  
ClientAliveInterval 3200  

I also checked the configuration of this VM in question in the Azure portal. I did not see any configuration parameters for setting ssh session time-out in the "Connect" area, under "Settings", nor did I see anything like that in any of the other configuration areas.

Currently, the problem is happening on at least one Rocky Linux 9 VM, and I have noticed it on other RHEL-based machines (Oracle, CentOS, etc.) running in Azure (but not on those running in other cloud platforms). This problem does not happen on an Ubuntu VM in Azure that I care for.

Before posting here, I checked the Azure ssh troubleshooting guide, various posts online, and searched this forum. None of the documentation or posts that I have found so far have pointed me in the direction of a solution, however.

I imagine that there must be some other configuration parameters to set ssh session idle time-out for Azure VMs, which I am not aware of. That, or perhaps, there is an include file or other configuration parameter changed on the OS somewhere that I've yet to find.

Any help to hunt down this strange problem would be very much appreciated. It's quite annoying. :D

Thank you!
Michela

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,443 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Cristian SPIRIDON 4,471 Reputation points
    2022-11-20T19:43:57.123+00:00

    Hi @Michela Toscano ,

    Azure public IP has a default timeout of 4 min that is not documented very clear. Following blog post explain how to configure linux kernel to do keep alive at a smaller that 240 secs interval:

    https://carsonip.me/posts/azure-tcp-idle-timeout-tcp-keepalive-python/

    Hope this helps!

    0 comments No comments