在Linux系统中,SFTP(SSH File Transfer Protocol)的日志记录和分析对于监控文件传输活动、排查问题和确保系统安全至关重要。以下是关于Linux SFTP日志记录与分析的一些关键步骤和要点:
/etc/ssh/sshd_config
文件。Subsystem sftp /usr/lib/openssh/sftp-server
LogLevel VERBOSE
LogLevel VERBOSE
会记录更多的调试信息,有助于分析。/var/log/auth.log
或/var/log/secure
中,具体取决于系统配置。sudo tail -f /var/log/auth.log
grep "sftp" /var/log/auth.log | grep "username"
grep "sftp" /var/log/auth.log | grep "Oct 10"
awk '/sftp/ {count[$1]++} END {for (user in count) print user, count[user]}' /var/log/auth.log
grep "Failed password" /var/log/auth.log | grep "sftp"
sudo nano /etc/logrotate.d/auth
添加以下内容:/var/log/auth.log {
rotate 7
daily
compress
missingok
notifempty
create 640 root adm
}
通过以上步骤,您可以有效地记录和分析Linux系统上的SFTP活动,从而提高系统的安全性和可管理性。