怎样用命令查找别人用ssh登录自己本地主机

来源:互联网 发布:2018人工智能展览会 编辑:程序博客网 时间:2024/04/30 15:25
ps -ef|grep sshd
root 1693 1 0 Aug13 ? 00:00:00 /usr/sbin/sshd #父进程号是1的是系统服务进程
root 12598 1693 2 14:59 ? 00:00:00 /usr/sbin/sshd #有这个进程说明有SSHD远程客户登录
root 12638 1693 0 15:02 ? 00:00:00 /usr/sbin/sshd #这是第二个登录用户
root 12633 12600 0 14:59 pts/0 00:00:00 grep sshd

二、根据登录上来的进程号找到用户进程
#ps -ef|grep 12598
root 12598 1693 0 14:59 ? 00:00:00 /usr/sbin/sshd
root 12600 12598 0 14:59 pts/0 00:00:00 -bash #第一个用户,居然还是用root登录的。

#ps -ef|grep 12633
root 12638 1693 0 15:02 ? 00:00:00 /usr/sbin/sshd
root 12640 12638 0 15:02 pts/1 00:00:00 -bash #第二个用户

三、根据bash进程的终端号pts/?来确定来源
[root@redhat root]# who -a|grep pts/1
root + pts/1 Aug 14 15:02 00:03 12640 (192.168.0.123) #登录来源IP192.168.0.123
[root@redhat root]# who -a|grep pts/0
root + pts/0 Aug 14 14:59 . 12600 (192.168.0.123) #登录来源IP192.168.0.123
原创粉丝点击