SSH:

We can set a timeout interval for ssh client who are idle or in inactive state. As soon as the idele user will reach the timeout interval, they will be logged off from server automatically

To set this up, you just need to perform some simple steps:

1) Open the file /etc/ssh/sshd_config which is ssh server configuration file and search the below given parameters and change them to read as:

ClientAliveInterval 180
ClientAliveCountMax 0

180 represents the no. of seconds after which the clients will be logged out if they idle. You can change it as per your need.

Save and close the file.

2) Now, restart sshd service:

[root@server ~]# service sshd restart
[root@server ~]# chkconfig sshd on

3) Thats it, now whenever a ssh client will be idle for 180 seconds i.e. 3 minutes, he will be automatically logged out by getting a message like this:

[root@server5 ~]# timed out waiting for input: auto-logout
Connection to 192.168.0.105 closed.

- See more at: http://www.switchroot.com/how-to-log-out-idle-ssh-clients-automatically#sthash.UnsbQR2d.dpuf

From:http://www.switchroot.com/how-to-log-out-idle-ssh-clients-automatically

The ssh "timed out waiting for input: auto-logout" messages is generated by ssh upon reaching a auto-logout after an inactivity time specified by the TMOUT environment variable. If this variable is not set your session will not be auto-logged out due to inactivity. If the environment variable is set, your session will be automatically closed/logged out after the amount of seconds specified by the TMOUT variable.

To see if your auto-logout variable is set and/or see what it is set to issue the following command:
 $ echo $TMOUT

Often this value is defined in /etc/profile (globally) or your user's profile (~/.profile or ~/.bash_profile).

To alter the auto-logout amount, set the TMOUT environment variable accordingly:
* TMOUT=600   #set an auto-logout timeout for 10 minutes
* TMOUT=1200  #set an auto-logout timeout for 20 minutes
* TMOUT=   #turn off auto-logout (user session will not auto-logout due to session inactivity)

This value can be set globally (e.g. TMOUT=1200) in the /etc/profile file; however, each user can override the value by setting the TMOUT variable in their personal profile file (~/.profile or ~/.bash_profile). To do this simply set the TMOUT variable as you like in your profile file.

Dont forget to source the file you changed to get the settings to take effect immediately or log out and log back in.

From:http://www.adercon.com/ac/node/39

Changing the Auto-Logout Timeout in SSH的更多相关文章

  1. MES Auto Logout

    如果您在车间使用MES,可能存在这种情况有人在仍然登录的情况下偶尔离开终端.如果一段时间不使用终端,我们是否可以让用户自动注销. 1 首先,我们有一条using语句: using System.Run ...

  2. linux shell except tcl login ssh Automatic interaction

    /*************************************************************************************** * linux she ...

  3. cisco ssh实验--附带配置脚本-2019.11.19

    cisco ssh实验

  4. SSH自动登录脚本

    原创转载请注明出处:https://www.cnblogs.com/agilestyle/p/11926792.html vi app-stg.sh #!/usr/bin/expect -f #aut ...

  5. 自动化运维,远程交互从服务器A上ssh到服务器B上,然后执行服务器B上的命令。

    第一种: ftp -v -n 192.168.0.1 21 <<! user ftp ftp123 bay ! 第二种: { echo -e "\n" echo -e ...

  6. golang的ssh包

    git clone https://github.com/golang/crypto.git,复制到 golang.org/x/ 目录下. 常常用来建立ssh连接发送一条命令,但有时需要模拟ssh客户 ...

  7. 关于Mac下的SSH客户端iterm2等配置

    linux后台开发的同学们晓得,在windows下有xshell\securecrt这样优秀的ssh客户端软件.mac下查找了下,有securecrt mac版,网上也有破解的,试用了一段时间,一个问 ...

  8. python ssh弱口令爆破多线程脚本及遇到的一些错误与问题

    练习写了个SSH弱口令爆破多线程脚本,遇到的问题 1.一开始想import pexpect 中的pxssh 然而却一直该有错误, ImportError: cannot import name spa ...

  9. Net::SSH::Perl 模块

    <pre name="code" class="python">Net::SSH::Perl - Perl client Interface to ...

随机推荐

  1. BST的删除

    #include<iostream> #include<math.h> #include<stdio.h> #include<stdlib.h> #in ...

  2. Linux学习之less命令

    less 工具也是对文件或其它输出进行分页显示的工具,应该说是linux正统查看文件内容的工具,功能极其强大.less 的用法比起 more 更加的有弹性.在 more 的时候,我们并没有办法向前面翻 ...

  3. fckeditor使用详解

    FCKEditor是一个很好的用于Web页面中的格式化文本编译控件.现在越来越多的论坛的发帖页面中更多的使用了这个控件,我们这里将如何在基于Java的web开发中使用FCKEditor控件的步骤提供给 ...

  4. 使用mysql_query()方法操纵数据库以及综合实例

    1.利用insert 语句添加记录 <? require('conn.php'); mysql_query( "insert into lyb ( title, content, au ...

  5. SingleNumber python实现

    Single Number Given an array of integers, every element appears twice except for one. Find that sing ...

  6. [LeetCode]题解(python):150-Evaluate Reverse Polish Notation

    题目来源: https://leetcode.com/problems/evaluate-reverse-polish-notation/ 题意分析: 给定一个数组,用这个数组来表示加减乘除,例如 [ ...

  7. ACM大数模板(支持正负整数)

    之前就保留过简陋的几个用外部数组变量实现的简单大数模板,也没有怎么用过,今天就想着整合封装一下,封装成C++的类,以后需要调用的时候也方便得多. 实现了基本的加减乘除和取模运算的操作符重载,大数除以大 ...

  8. SQL Server 表压缩

    表压缩有三个选项 1.page 2.row 3.none ----------------------------------------------------------------------- ...

  9. sql like 通配符 模糊查询技巧及特殊字符

    最近碰到like模糊匹配的问题,找到一些答案接触迷惑,觉得有知识是自己忽略的,现在整理出来,既强化记忆,又是一次记录,以下转自一篇Blog,关于sql server like的通配符和字符带通配符的处 ...

  10. 2016 Multi-University Training Contest 5&6 总结

    第五场和第六场多校都打得很糟糕. 能做到不以物喜不以己悲是假的,这对队伍的情绪也可以算上是比较大的打击. 很多时候我们发现了问题,但是依旧没有采取有效的方法去解决它,甚至也没有尝试去改变.这是一件相当 ...