Last active
November 22, 2023 10:58
-
-
Save johnybradshaw/de3bc410f3920cee5b839b96365bc0a5 to your computer and use it in GitHub Desktop.
Automatically logout inactive users on physical/virtual terminal, but ignore SSH
This file contains 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
#!/bin/bash | |
################################################################################################ | |
# Usage # | |
################################################################################################ | |
# Add this to /etc/profile.d/autologout-tty.sh | |
################################################################################################ | |
# Auto-logout for tty sessions after a period of inactivity | |
if [[ "$(tty)" =~ /dev/tty[0-9]+ ]] || [[ "$(tty)" =~ /dev/ttyS[0-9]+ ]]; then | |
# Set TMOUT to 600 seconds (10 minutes) for tty and ttyS sessions | |
export TMOUT=600 | |
readonly TMOUT | |
RED='\033[1;31m' | |
NC='\033[0m' | |
echo -e "\n\nTo exit the console, press ${RED}CTRL+A${NC} then ${RED}D${NC} to return to the host machine,\nand then press ${RED}CTRL+D${NC} to return to the Lish menu\n\n" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment