9

I'm trying to enable logging for vsftpd so I can see uploads, downloads, and, more specifically, deletion of files; however, I haven't even been able to get normal logging working with a fresh install of centos 6.

Setup:

[root@sftp01 vsftpd]# cat /etc/centos-release 
CentOS release 6.9 (Final)

[root@sftp01 vsftpd]# netstat -naplt
    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
    tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN      367/vsftpd          
    tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      507/sshd            
    tcp        0      0 :::22                       :::*                        LISTEN      507/sshd   

[root@sftp01 ~]# yum repolist
Loaded plugins: fastestmirror
Determining fastest mirrors
epel/metalink                                                                                                          |  12 kB     00:00     
 * base: mirrors.usc.edu
 * epel: mirror.math.princeton.edu
 * extras: repos.lax.quadranet.com
 * updates: mirror.eboundhost.com
base                                                                                                                   | 3.7 kB     00:00     
base/primary_db                                                                                                        | 4.7 MB     00:01     
epel                                                                                                                   | 4.3 kB     00:00     
epel/primary_db                                                                                                        | 5.9 MB     00:00     
extras                                                                                                                 | 3.4 kB     00:00     
extras/primary_db                                                                                                      |  29 kB     00:00     
updates                                                                                                                | 3.4 kB     00:00     
updates/primary_db                                                                                                     | 3.1 MB     00:00     
repo id                                         repo name                                                                               status
base                                            CentOS-6 - Base                                                                          6,706
epel                                            Extra Packages for Enterprise Linux 6 - x86_64                                          12,380
extras                                          CentOS-6 - Extras                                                                           45
updates                                         CentOS-6 - Updates                                                                         565

Default config:

[root@sftp01 vsftpd]# grep -v ^# /etc/vsftpd/vsftpd.conf 
anonymous_enable=YES
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=YES

pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

Connecting via sftp for a system user works fine. I've tried many different combinations for the logging options (dual_log_enable, vsftpd_log_file, xferlog_file and others listed in the man page) and creating the log files manually with various permissions.

How do I get vsftpd to log?


updated:

[root@sftp01 vsftpd]# cat /etc/vsftpd/vsftpd.conf
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
connect_from_port_20=YES
listen=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

xferlog_std_format=YES
xferlog_enable=YES
vsftpd_log_file=/var/log/vsftpd.log
log_ftp_protocol=YES

[root@sftp01 vsftpd]# /etc/init.d/vsftpd restart
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]

After logging in with sftp, uploading a file, deleting that file, and logging off (no ftp-related info):

[root@sftp01 vsftpd]# tail -f /var/log/*
==> /var/log/secure <==
Aug 29 13:48:22 sftp01 sshd[1253]: Accepted password for test from 192.168.10.10 port 35825 ssh2
Aug 29 13:48:22 sftp01 sshd[1253]: pam_unix(sshd:session): session opened for user test by (uid=0)
Aug 29 13:48:22 sftp01 sshd[1255]: subsystem request for sftp
Aug 29 13:48:31 sftp01 sshd[1253]: pam_unix(sshd:session): session closed for user test

3 Answers 3

7

You will need to add a location for log file

vsftpd_log_file=/var/log/vsftpd.log

For verbose logging you will need to add

log_ftp_protocol=YES

And comment

xferlog_std_format=YES
1
  • 1
    You should also use service vsftpd restart not just vsftpd restart
    – Zoey Hewll
    Commented Jun 22, 2018 at 3:32
2

In the logs we can see that connection is made to SFTP server. If you in reality want to configure SFTP and not FTP, that server can be configured in /etc/ssh/sshd_config, snip from that file:

# override default of no subsystems
Subsystem   sftp    /usr/libexec/openssh/sftp-server

FTP, FTPS and SFTP are not the same thing. SFTP uses port 22 by default. FTP and FTPS use port 21 by default (and possibly other ports).

With CentOS 8, I got vsftpd logging working by configuring below in /etc/vsftpd/vsftpd.conf:

# This is by default YES
xferlog_enable=YES

# This was changed from default YES to NO.
# This was actually the setting preventing from logging properly.
xferlog_std_format=NO

# Changed logfile from default as this makes more sense to me
xferlog_file=/var/log/vsftpd.log

# Enable verbose logging
log_ftp_protocol=YES
3
  • If I'm understanding you correctly, you're really just adding another OS that user2827958's answer works for; is that correct?
    – Jeff Schaller
    Commented Oct 7, 2019 at 17:48
  • More important point than the OS was that the topic starter is actually probably using SFTP and not FTP. I was super confused about FTP and SFTP when I started configuring them the first time. I hope that the snip from the ssh_config will help somebody else to realize that they could just use SFTP which running quite often by default, instead of intensive research of FTP. Secondly I was wondering maybe half an hour why my CentOS 8 is not logging with FTP, so hopefully this helps the next person. I would have added just a comment to previous answer if I could comment the posts.
    – Eastman
    Commented Oct 7, 2019 at 18:02
  • This is actually the only answer that addresses the crux of the problem; vsftpd != sftp
    – tink
    Commented Mar 3, 2021 at 22:17
1

Connections from sFTP have nothing to do with VSFTPD but run over SSHD.
sFTP connections will be unaffected by these changes, only FTP connections.

I got it working with Centos 7.5 by changing the following:

log_ftp_protocol=YES
xferlog_enable=YES
xferlog_std_format=NO

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .