Add the following lines at the end of the /etc/profile
file to start a screen
session each time a user logs in to a virtual console or remotely:
SCREENEXEC="screen"
if [ -w $(tty) ]; then
trap "exec $SCREENEXEC" 1 2 3 15
echo -n 'Starting session in 10 seconds'
sleep 10
exec $SCREENEXEC
fi
Note that each time a new session starts, a message will be displayed and the user will have to wait ten seconds. To adjust the time to wait before starting a session, change the value after the sleep
command.
Add the following lines to the /etc/screenrc
configuration file to close the screen
session after a given period of inactivity:
idle 120 quit
autodetach off
This will set the time limit to 120 seconds. To adjust this limit, change the value after the idle
directive.
Alternatively, you can configure the system to only lock the session by using the following lines instead:
idle 120 lockscreen
autodetach off
This way, a password will be required to unlock the session.