1. 查明登陆端口和登陆人
$ who
secure :0 2015-07-22 03:03 (:0)
secure pts/0 2015-07-23 00:27 (192.168.176.1)
secure pts/1 2015-07-23 00:29 (:0)
secure pts/2 2015-07-23 01:44 (192.168.176.1)
2. 通知登陆用户将要关闭他
$ echo "I will close your connection" > /dev/pts/2
3. 关闭用户连接
3.1. 关闭某用户某链接
#安装fuser包
$ yum install -y psmisc
#关闭某ssh会话
$ fuser -k /dev/pts/2
3.2. 关闭指定用户所有链接
#查看ssh登录用户
ps aux |grep sshd
#关闭指定用户所有链接
kill -9 xxx
4. 验证是否已经关闭
$ who
secure :0 2015-07-22 03:03 (:0)
secure pts/0 2015-07-23 00:27 (192.168.176.1)
secure pts/1 2015-07-23 00:29 (:0)