如果文件 /var/log/wtmp 存在,则可以使用命令 lastb 跟踪无效的登录尝试。
下面给出了导致错误或者错误登录尝试的一些可能原因:
- 由于输入错误,登录时输入了错误的密码。
- cron 中用于通过 ssh 连接的用户的密码已更改。
- 如果任何黑客试图使用随机/通用用户 ID 进行连接。
Last login: Sat Apr 21 16:24:24 UTC 2018 on pts/3 Last failed login: Sat Apr 21 17:44:04 UTC 2018 from 185.189.58.212.ptr.cy4n.net on ssh:notty There was 1 failed login attempt since the last successful login.
下面给出了 lastb 命令的示例输出。
# lastb -a | more admin ssh:notty Sat Apr 21 17:44 - 17:44 (00:00) 185.189.58.212.ptr.cy4n.net admin ssh:notty Sat Apr 21 17:44 - 17:44 (00:00) 185.189.58.212.ptr.cy4n.net admin ssh:notty Sat Apr 21 17:44 - 17:44 (00:00) 185.189.58.212.ptr.cy4n.net admin ssh:notty Sat Apr 21 17:44 - 17:44 (00:00) 185.189.58.212.ptr.cy4n.net ...
命令 last 和 lastb 搜索文件 /var/log/wtmp(或者由 -f 标志指定的文件)并显示自该文件创建以来登录(和退出)的所有用户的列表。
如果该文件尚不存在,我们可以触摸它。
# touch /var/log/wtmp
last 和 lastb 都报告 /var/log/wtmp 的内容。
默认是报告事件的月份、日期和时间。
但是,该文件中可能有多年的数据,月/日可能会令人困惑。
-F 标志将报告完整日期:
# lastb -F | more user ssh:notty 1.186.112.64 Sun Apr 22 03:49:47 2018 - Sun Apr 22 03:49:47 2018 (00:00) user ssh:notty 1.186.112.64 Sun Apr 22 03:49:44 2018 - Sun Apr 22 03:49:44 2018 (00:00) user ssh:notty 1.186.112.64 Sun Apr 22 03:49:40 2018 - Sun Apr 22 03:49:40 2018 (00:00) ...
注意:我们计算机上的记帐系统会跟踪使用用户统计信息并保存在当前的 /var/log/wtmp 文件中。
该文件由 init 和 login 进程管理。
日期:2020-09-17 00:13:15 来源:oir作者:oir
