I'm wondering if this is possible. I'd like users to be able to launch screen on some of our hosts for the purpose of multiplexing their terminal login sessions. However, I don't want them to be able to detach the screen and leave it running in the background.
The reason for this being that the only way to log in to these machines is through a cluster job submission system, so if a screen becomes detached and the user logs off the only way to get back would be if they happened to land back on the same node on their next job submissions.
You can do a 'soft' disable of detaching by putting
in
.screenrc
, which removes the default ^A D keybinding for detach. Or maybeDoing a hard disable of detach, including the command line forms, would take forking your own version of
screen
and coding out the capability. Which, y'know, can be done, it being an open source project and all.Here is a hack you could put into a bash script and run every minute with cron to kill detached sessions. Not the cleanest solution though :-P
Read the screen manpage for autodetach. This will make sure it simply kills everything if their connection is disabled.
You'll still want the other solutions mentioned...
They'll always be able to just disconnect without closing their terminal(s), unless you hack auto-kill into screen of course.
Since detaching screen leaves the user logged in, you could add into the login script a check to see which server the user is already logged in to. This would be more work than just disabling detach, but would be far more useful to your users.
An idea for the script: iterate through the servers,
grep
ing the outpot ofwho
, and then logging the user in to the server that reports them logged in first; otherwise, log them in as they would be now (to handle when a user logs out cleanly).