Linux 如何查看和关闭 ssh pts/n 远程登录用户 – 21运维
通知: .-...

Linux 如何查看和关闭 ssh pts/n 远程登录用户

linux 21运维 89浏览

1,查看远程登录用户和定位到自己是哪一个终端

[[email protected] worker]# w
 15:27:07 up 300 days,  4:18,  4 users,  load average: 0.07, 0.15, 0.11
USER     TTY      FROM              [email protected]   IDLE   JCPU   PCPU WHAT
worker pts/2    182.150.44.71    15:08    0.00s  0.03s  0.02s sshd: worker [priv]
worker pts/3    182.150.44.71     15:08   17:33   0.00s  0.02s sshd: worker [priv]
worker pts/5    182.150.44.71     15:26    9.00s  0.00s  0.00s -bash
worker pts/6    182.150.44.71    15:26    8.00s  0.00s  0.00s -bash
[[email protected] worker]# who  am i
worker pts/2        2016-10-09 15:08 (182.150.56.79)

2,发送消息给要关闭的终端用户

[[email protected] worker]# echo -e  "i will close your connection in one minute,please contack devops in time" >/dev/pts/3

对方收到的信息如下:

[[email protected] worker]# who am i
worker pts/3        2016-10-09 15:08 (182.150.56.79)
[[email protected] worker]# i will close your connection in one minute,please contack devops in time

3,关闭某一个远程登录终端

[[email protected] worker]# fuser -k /dev/pts/3
/dev/pts/3:          30355 30408 30409

重新w查看,3的终端已经不在了。

[[email protected] worker]# w
 15:31:40 up 300 days,  4:22,  3 users,  load average: 0.19, 0.16, 0.11
USER     TTY      FROM              [email protected]   IDLE   JCPU   PCPU WHAT
worker pts/2    182.150.44.71     15:08    0.00s  0.03s  0.02s sshd: worker [priv]
worker pts/5    182.150.44.71    15:26    4:42   0.00s  0.00s -bash
worker pts/6    182.150.44.71    15:26    4:41   0.00s  0.00s -bash

 

 

转载请注明:21运维 » Linux 如何查看和关闭 ssh pts/n 远程登录用户