2

I want to make my terminal freeze, if it is not used for more than 15 minutes. I do have the option to edit the .ssh/sshd_config.

But I want a script instead of this..

2
  • Could you specify freeze a bit more? You want it to behave like a screensaver? Or logout/exit? And why not use the sshd_config?
    – ahilsend
    Jul 30, 2013 at 7:34
  • @ahilsend: If a terminal is idle for 15 min, and after that if I try to access that terminal, it shouldn't be accessible unless you do something else like entering a password or entering a new key combination etc.
    – peepeep
    Jul 30, 2013 at 9:16

2 Answers 2

3

See this question for possible solutions.

If you use screen you can press Ctrl-a x to manually lock your session. Your user password is required to unlock it again. For an automatic locking after 15 minutes (900 seconds) just specify idle 900 lockscreen in your .screenrc.

There is also vlock which doesn't require an already running screen session but has to be run manually.

14
  • Setting time in screenrc will be locking the entire system right. I just want to lock the terminal session.
    – peepeep
    Jul 30, 2013 at 8:37
  • No, it won't lock the entire system. Just your screen session(s).
    – scai
    Jul 30, 2013 at 8:58
  • Thanks for the reply. Its not just about the screen sessions. I want lock any of the terminal which is idle for more than 15 minutes. Is there any options for that?
    – peepeep
    Jul 30, 2013 at 9:15
  • 1
    I think this will do.. Thank you very much for the help :)
    – peepeep
    Jul 30, 2013 at 17:46
0

Add the following lines in user's .bashrc

if [ -z "$STY" ]; then
    exec screen -ARR
fi

Edit the file .screenrc

idle 900 lockscreen

It will lock the screen which is idle for more than 15 minutes and if you try to access it again, you will have to enter the password.

1
  • Is there a way to exit the screen session instead of lock the screen since i dont have a password set so it traps the user.
    – mRyan
    Jan 18, 2023 at 17:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .