1. 程式人生 > 其它 >Linux 登入驗證日誌分析(secure)

Linux 登入驗證日誌分析(secure)

技術標籤:linuxsecure伺服器巡檢linux登入失敗

主要用途

伺服器放在公網,需要定期進行伺服器巡檢,檢查登入驗證日誌:/var/log/secure,發現存在大量登入失敗請求;
通過以下命令,可以大致分析當前安全現狀,為安全加固提供依據。

1、哪些IP在爆破主機的root帳號:    
grep "Failed password for root" /var/log/secure | awk '{print $11}' | sort | uniq -c | sort -nr 
​
2、哪些IP在爆破使用者:
grep "Failed password"
/var/log/secure|perl -e 'while($_=<>){ /from(.*?) port/; print "$1\n";}'|sort -nr|uniq -c |sort -nr 3、爆破使用者名稱字典 grep "Failed password" /var/log/secure|perl -e 'while($_=<>){ /for(.*?) from/; print "$1\n";}'|sort -nr|uniq -c |sort -nr