大网数据广告活动
服务器运维问答

Finding deleted/imported files in SFTP server using logs

· 52CE 我爱测

We have an SFTP server, I am trying to find out if some specific files have been deleted from the server or if they have even imported to the server or not. I'm going through the log files under /var/log but coudn't find out rele…

问题原文

原帖链接 · Matrix · CC BY-SA 4.0

We have an SFTP server, I am trying to find out if some specific files have been deleted from the server or if they have even imported to the server or not. I'm going through the log files under /var/log but coudn't find out relevant logs so far.

I'm wondering in which log file I can find such infomation?

Any help would be appreciated.

Updated:

Based on the answer and the link: enter link description here I have modified config file which parts of it looks like below:

Subsystem sftp internal-sftp -f AUTH -l INFO

# Force sftp and chroot jail for members of sftp group
Match group sftp
ForceCommand internal-sftp
ChrootDirectory /sftp/%u

# Members of sftp-glob have access to all user folders
Match group sftp-glob
ForceCommand internal-sftp
ChrootDirectory /sftp


# Enable this for more logs
LogLevel VERBOSE

Then restarted sshd:

sudo systemctl restart sshd

In this case I can only see the logs created by admin user(me) under /var/log/auth.log

Jan 17 12:57:50 ios-sftp internal-sftp[5262]: remove name "/tmp/test.txt"

For logging the chrooted users actions I have done this:

cd /sftp 
sudo mkdir dev
sudo chmod 755 dev
sudo touch dev/log
sudo mount --bind /dev/log dev/log

However I still can't see the other users logs in /var/log/auth.log if they upload or delete files.

It started to work after fixing config file by changing ForceCommand internal-sftp to ForceCommand internal-sftp -f AUTH -l INFO

Subsystem sftp internal-sftp -f AUTH -l INFO

# Force sftp and chroot jail for members of sftp group
Match group sftp
ForceCommand internal-sftp -f AUTH -l INFO
ChrootDirectory /sftp/%u

# Members of sftp-glob have access to all user folders
Match group sftp-glob
ForceCommand internal-sftp -f AUTH -l INFO
ChrootDirectory /sftp


# Enable this for more logs
LogLevel VERBOSE

now I can see the logs under /var/log/auth.log:

Jan 18 10:13:02 user-sftp internal-sftp[7466]: set "/folder1/folder2/myfile.xml" modtime 20210106-10:32:58

已采纳解答

原帖链接 · vidarlo · CC BY-SA 4.0

By default transferred files is not logged by sftp in system logs, only connection-disconnection.

It can be enabled for future transactions, but that probably won't help you solving your problem at hand - but it may solve it for the future.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2022-01-14)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。