Debian SFTP日志分析方法如下:
查看日志文件
/var/log/auth.log
,使用命令 cat /var/log/auth.log | grep 'sftp'
过滤SFTP相关条目。tail -f /var/log/auth.log | grep 'sftp'
。过滤关键信息
grep 'username' /var/log/auth.log
。grep 'UPLOAD'
或 grep 'DOWNLOAD'
(部分系统需结合具体日志格式)。grep 'Failed password' /var/log/auth.log
。统计与分析
awk '/username/ {print $1}' /var/log/auth.log | sort | uniq -c
。awk
按日期筛选(需日志包含时间戳)。工具辅助分析
注意事项
chmod 600 /var/log/auth.log
。/etc/logrotate.d/
下的配置。参考来源: