ftp客户端中使用sftp协议如何记录操作日志?
经过实践,secure-crt上链接sftp session的操作不会被记录下来,命令行应该很少会用,毕竟门槛在呢。
而其他ftp客户端则会被记录下来,包括进入目录,增删改查文件。
vim /etc/ssh/sshd_config
修改
Subsystem sftp /usr/libexec/openssh/sftp-server -f local5 -l INFO //如果注释掉,则不支持sftp连接
默认日志等级
#LogLevel INFO
vim /etc/rsyslog.conf(记录2分日志,也可以单独记录日志, /var/log/messages这行添加local5.none)
添加
auth,authpriv.*,local5.* /var/log/sftp.log
systemctl restart sshd
systemctl restart rsyslog
日志切割
cat /etc/logrotate.d/sftp
/var/log/sftp.log
{
daily
rotate 31
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
endscript
}
参考
rsyslog日志服务详解
https://blog.51cto.com/6638225/1862902
扩展阅读
How To Enable SFTP Without Shell Access on CentOS 7
https://www.digitalocean.com/community/tutorials/how-to-enable-sftp-without-shell-access-on-centos-7