Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

5 Answers

up vote 1 down vote accepted
echo autodetach off >> ~/.screenrc

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...

share|improve this answer
    
This combined with with rebinding the detach key will probably do what I want. –  Kamil Kisiel Jun 25 '09 at 23:19
add comment

You can do a 'soft' disable of detaching by putting

bind d

in .screenrc, which removes the default ^A D keybinding for detach. Or maybe

bind d echo Don't detach screens, it won't work because of the cluster.

Doing 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.

share|improve this answer
3  
+1 for mentioning custom modifications to an open source project. Yay open source! –  Evan Anderson Jun 25 '09 at 18:05
add comment

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

screen -S $(screen -ls | grep Detached | awk '{ print $1}') -X kill
share|improve this answer
add comment

They'll always be able to just disconnect without closing their terminal(s), unless you hack auto-kill into screen of course.

share|improve this answer
    
The dirty hack of turning off autodetach... –  womble Jun 26 '09 at 0:19
add comment

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, greping the outpot of who, 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).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.