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

  • 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 '13 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 '13 at 9:16

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.

| improve this answer | |
  • Setting time in screenrc will be locking the entire system right. I just want to lock the terminal session. – peepeep Jul 30 '13 at 8:37
  • No, it won't lock the entire system. Just your screen session(s). – scai Jul 30 '13 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 '13 at 9:15
  • 1
    I think this will do.. Thank you very much for the help :) – peepeep Jul 30 '13 at 17:46

Add the following lines in user's .bashrc

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

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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