在 CentOS 系統中,您可以通過查看 /var/log/secure
文件來追蹤登錄嘗試
打開終端。
輸入以下命令以使用 grep
命令搜索登錄嘗試:
grep 'sshd' /var/log/secure
這將顯示與 SSH 登錄嘗試相關的所有日志條目。
awk
命令過濾日志。例如,要查看 2021 年 10 月 1 日的登錄嘗試,請輸入以下命令:awk '$0 >= "[2021-10-01 00:00:00]" && $0 <= "[2021-10-01 23:59:59]"' /var/log/secure | grep 'sshd'
tail
命令:tail -f /var/log/secure | grep 'sshd'
這將實時顯示新的登錄嘗試。
head
命令。例如,要查看最近的 10 條登錄嘗試,請輸入以下命令:grep 'sshd' /var/log/secure | head -n 10
通過這些方法,您可以追蹤 CentOS 系統中的登錄嘗試并分析潛在的安全問題。