Is it possible to set timeout on Linux screen session


 
Thread Tools Search this Thread
Operating Systems Linux Is it possible to set timeout on Linux screen session
# 1  
Old 01-09-2018
RedHat Is it possible to set timeout on Linux screen session

Hello friends,

I work on Linux servers via SSH (putty) and run "screen" to preserve my sessions so I can attach/detach them at anytime I wish without losing the connectivity/process disruption which is working perfectly fine.

As my team members also have root access to those servers, it is very much possible for them to attach "MY" sessions and can see what I'm doing. Is there anyway I can't allow them to do that? To solve this issue (upto some extent), setting a time-out on my sessions would help a bit. In other words, is it possible to set a timeout on screen session within which I should re-attach (after detaching) the screen session with 12 hours (for eg timeout set to 12 hours) else that screen session should be auto-killed. Any thoughts on tailoring this requirement would be great.

Many thanks!
# 2  
Old 01-09-2018
Example use of the TMOUT variable with the bash shell:

Linux: TMOUT To Automatically Log Users Out - nixCraft

Note readonly - no user can change the variable after it is set.
These 2 Users Gave Thanks to jim mcnamara For This Post:
# 3  
Old 01-10-2018
Thanks jim.

But unfortunate this doesn't help me as I always have something running on my sessions (they are not idle to use TMOUT option). Basically I need my sessions to be killed automatically (forcibly) in case I don't attach to that screen session within certain time (like 12 hours or so). I guess this is more specific to "screen" feature i guess (based on it's man page there seems to be no such option), but if we could setup some alternative way to achieve it would be great.

Best,
# 4  
Old 01-10-2018
I don't think screen can do this. Nothing prevents root from barging in and changing your screen settings back, anyway.

You can't defend from root.
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 01-10-2018
Thanks Corona.

Upon my further thoughts, to make it simple, I would like to setup like irrespective of anything, my current login session (bash process) should be killed after 12 hours (No matter of what my shell is running).

For example:
Code:
root@Ubuntu16:~# who
root     pts/1        2018-01-10 20:51 (192.168.1.64:S.0)
root@Ubuntu16:~# screen -ls
There is a screen on:
        1624.pts-0.Ubuntu16     (10/01/18 20:51:11)     (Attached)
1 Socket in /var/run/screen/S-root.
root@Ubuntu16:~# kill -9 1624

How can I achieve the above without using cron or atjobs or without leaving any record/file/log on the Server. Basically the above kill should be scheduled to run after 12 hours while letting me work on the shell until then.

Please advise, thanks!
# 6  
Old 01-10-2018
You cannot defend from root.

You leave behind something that waits 12 hours then kills it:
Code:
( sleep 86400 && kill $$ ) & # Kill parent in 12 hours
exec screen # Replace parent process with screen

...but nothing prevents them from finding and killing it first.

And the more complicated you build your rube-goldberg machine, the more likely they are to notice that someone's doing odd things to the system.
# 7  
Old 01-10-2018
Quote:
Originally Posted by Corona688
You cannot defend from root.
Yes ofcourse!

Quote:
Originally Posted by Corona688
You leave behind something that waits 12 hours then kills it:
Code:
( sleep 86400 && kill $$ ) & # Kill parent in 12 hours
exec screen # Replace parent process with screen

This worked great, atleast solves my purpose upto some extent Smilie

Quote:
Originally Posted by Corona688
...but nothing prevents them from finding and killing it first.
Actually I need this. In case I log back into server within 12 hours, I might just abort this kill (may initiate another later), if required.

Quote:
Originally Posted by Corona688
And the more complicated you build your rube-goldberg machine, the more likely they are to notice that someone's doing odd things to the system.
This is not an issue Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

Set timeout value for ssh session to HMC?

Friends, Could anyone let me know - how to set the timeout value for ssh session to HMC? My HMC version is -- V7R7.4.0. I'm sure the version doesn't have anything to do with it. Thanks, -- Souvik (2 Replies)
Discussion started by: thisissouvik
2 Replies

2. Solaris

Session timeout setting in server

Hi All I need to set timeout of login session of a user if a user is idle for some time. I know the TMOUT setting but it work with only BASH & KORN shell only as I need to set for Bourne shell also. I am trying to put "ClientAliveInterval 300" in sshd_config & restart or refreshing the... (1 Reply)
Discussion started by: sb200
1 Replies

3. UNIX for Dummies Questions & Answers

Putty Session Timeout

Hi, I had add the following line into .profile and .bash_profile for the timeout session to avoid putty close automatically : timeout=10800 However, i still keep encounter session time out every after 60 seconds. Can anyone please help advice. Many Thanks! (2 Replies)
Discussion started by: wancy
2 Replies

4. Shell Programming and Scripting

set Net:SSH:Expect timeout and set it again.

SSHing into a machine can take a few seconds, but after I'm in, the commands return quickly. I was wondering if the timeout setting can be changed once I'm logged into the machine. Does anyone know if this can be set on the fly? The problem here is, if I have to set timeout = 10, it'll take 10... (1 Reply)
Discussion started by: mrwatkin
1 Replies

5. AIX

Unix session timeout?

We recently moved servers to a new data center, and now we're experiencing user sessions timing out after non-activity. We didnt experience this before, or know of any timeout settings that may have been changed. Any things I can check out on the server? (3 Replies)
Discussion started by: NycUnxer
3 Replies

6. Shell Programming and Scripting

session timeout for shell script

I am executing test.sh script. But this script takes lot of time and in the meantime the shell timeouts without completing the script. Is there any command which will continue processing the script. Thanks (3 Replies)
Discussion started by: infyanurag
3 Replies

7. Solaris

Solaris 8 - Session timeout

Hi, anyone Audit requirement to set the Solaris 8 server session timeout to 180 sec , Please advice how can I do it .... Thanks (3 Replies)
Discussion started by: civic2005
3 Replies

8. Solaris

Setting Screen Lock Timeout

Hello; I have Solaris 2.6 installed on many Sun AXI Ultra Sparc IIi systems. I want to set the Lock Screen global timeout for all users to 15 minutes. I read the Solaris CDE guide which instructed me to create a /etc/dt/config/C/sys.resources file and changed the timout to 15 minutes in... (1 Reply)
Discussion started by: rambo15
1 Replies

9. UNIX for Dummies Questions & Answers

telnet session timeout

hi, we can set something such that if the user has been idle for a while, it will auto disconnect. where to do so? thanks (6 Replies)
Discussion started by: yls177
6 Replies
Login or Register to Ask a Question