From time to time, I need to access the physical console (Hyper-V VM) to make changes but I sometimes forget to log out when I am done with it.
Is there a way to log out of that session when idle? How can I have more control for timeouts for different user and access method?
- Physical console (all users) - logout after 10 minutes of inactivity
- screen sessions - never logout
- user1 - SSH logout after 15 minutes of inactivity
- user2 - SSH logout after 1 hour of inactivity
- user3 - Telnet logout after 1 hour of inactivity
I’m not entirely sure why you would have to use the Hyper-V Manager for management vs. an ssh session ? (The HV Manager really has been clunky for me, and doesn’t properly support text copy and paste, so I try to avoid it at all costs…)
Nevertheless, if you wish to set a system-wide setting–that is, for ALL users–then you would need to edit the /etc/systemd/logind.conf file, then find the line similar to this:
Basically you need to un-comment this line (remove the ‘#’), then set it to the maximum number of seconds you wish for all user sessions to have until they time out. 600 = 10 minutes, 900 = 15 minutes, and so on…
Once you’ve made the desired change, save the file, then be sure to restart the service so the new setting will take effect:
# systemctl restart systemd-logind
If you really want to get specific, per-user settings, then I suggest you research the TMOUT setting for user profiles. An excellent guide on this from nixCraft can be found here .