在 Linux 系统中,lastb 是一个用于查看用户登录失败记录的实用工具。
当直接运行 lastb 命令时,默认会读取系统日志文件 /var/log/btmp,并列出所有尝试登录但失败的用户信息。
lastb [-adRx][-f ][-n ][用户名...][终端编号...]
常用选项:
options:
username:
tty:
查看所有失败的登录尝试:
# lastb ... zgg ssh:notty 143.198.176.57 Thu Apr 7 11:27 - 11:27 (00:00) zgg ssh:notty 143.198.176.57 Thu Apr 7 11:27 - 11:27 (00:00) zf ssh:notty 143.198.176.57 Thu Apr 7 11:27 - 11:27 (00:00) za ssh:notty 143.198.176.57 Thu Apr 7 11:27 - 11:27 (00:00) zeng ssh:notty 143.198.176.57 Thu Apr 7 11:27 - 11:27 (00:00) zf ssh:notty 143.198.176.57 Thu Apr 7 11:27 - 11:27 (00:00) zette ssh:notty 143.198.176.57 Thu Apr 7 11:27 - 11:27 (00:00) z310 ssh:notty 143.198.176.57 Thu Apr 7 11:27 - 11:27 (00:00)btmp begins Fri Apr
1 07:38:45 2025
仅显示前5条失败登录记录:
# lastb -n 5 mos ssh:notty 194.31.98.204 Thu Apr 28 16:52 - 16:52 (00:00) user ssh:notty 194.31.98.204 Thu Apr 28 16:52 - 16:52 (00:00) user ssh:notty 194.31.98.204 Thu Apr 28 16:52 - 16:52 (00:00) user ssh:notty 194.31.98.204 Thu Apr 28 16:52 - 16:52 (00:00) user ssh:notty 194.31.98.204 Thu Apr 28 16:52 - 16:52 (00:00)btmp begins Fri Apr 1 07:38:45 2025