Erdrick
Posts: 5
Joined: Sun Dec 17, 2017 7:26 pm

vsftpd passive

Sun Dec 17, 2017 7:41 pm

Hello everyone,

Well, I have run out of options here. I can not get passive to work with vsftpd. I currently have an FTP server running on a windows pc. My goal is to transfer the server to my raspberry pi. It is setup to run in basic FTP. I get it, that isn't safe due to sniffers and what not. This is a generic ftp I use to share media with a few friends. SFTP just isn't worth the trouble right now. Running in standalone mode works just fine but as soon as I attempt to engage the passive mode, the connect fails. I get "Connection attempt failed with "ECONNREFUSED - Connection refused by server"." I have tried everything I can think of and everything I have found searching for the answer. I have redirected the ports to the pi. This fails even trying to connect via the local lan. I also opened ports in iptable, that didn't help.

Code: Select all

# Is the server active?
listen=YES
listen_port=21
pasv_enable=YES
pasv_max_port=10100
pasv_min_port=10090
port_enable=YES
pasv_address=192.168.1.50
# if pasv_address_resolve=YES, pasv_address should be a name, e.g. ftp.blah.com
#pasv_addr_resolve=YES
# Enable IPV6?
listen_ipv6=NO
#
# Allow anyone to connect
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=NO
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# If enabled, vsftpd will display directory listings with the time
# in  your  local  time  zone.  The default is to display GMT. The
# times returned by the MDTM FTP command are also affected by this
# option.
use_localtime=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/vsftpd.log
#
# If you want, you can have your log file in standard ftpd xferlog format.
# Note that the default log file location is /var/log/xferlog in this case.
#xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
ftpd_banner=WARNING: Only authorized users are allowed to access this US government server. All unauthorized users are required to disconnect now.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd.banned_emails
#
# You may restrict local users to their home directories.  See the FAQ for
# the possible risks in this before using chroot_local_user or
# chroot_list_enable below.
chroot_local_user=YES
user_sub_token=$USER
local_root=/home/$USER/FTP
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
#chroot_local_user=YES
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd.chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# Customization
#
# Some of vsftpd's settings don't fit the filesystem layout by
# default.
#
# This option should be the name of a directory which is empty.  Also, the
# directory should not be writable by the ftp user. This directory is used
# as a secure chroot() jail at times vsftpd does not require filesystem
# access.
secure_chroot_dir=/var/run/vsftpd/empty
#
# This string is the name of the PAM service vsftpd will use.
pam_service_name=vsftpd
#
# This option specifies the location of the RSA certificate to use for SSL
# encrypted connections.
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
ssl_enable=NO
#
# Uncomment this to indicate that vsftpd use a utf8 filesystem.
#utf8_filesystem=YES
allow_writeable_chroot=NO





Erdrick
Posts: 5
Joined: Sun Dec 17, 2017 7:26 pm

Re: vsftpd passive

Sun Dec 17, 2017 8:55 pm

If someone has a suggestion I would love to hear it. Out of frustration I just installed PROFTPD and the passive for it works out of the box.

Seems to have lot more settings and options.

knute
Posts: 452
Joined: Thu Oct 23, 2014 12:14 am
Location: Texas
Contact: Website

Re: vsftpd passive

Sun Dec 17, 2017 10:07 pm

Passive works out of the box on vsftpd. You don't need all those configuration entries to get it to work (I really don't think you want listen=YES). There is one caveat to that though, do you have ufw running? If so you need to tell it to allow the related connection.

iptables -A PREROUTING -t raw -p tcp –dport 21 -j CT –helper ftp

Will allow passive ftp connections through the firewall. You also need to open port 21.

I've got a bug report into ufw about this but it is going to take a while I think.

Erdrick
Posts: 5
Joined: Sun Dec 17, 2017 7:26 pm

Re: vsftpd passive

Tue Dec 19, 2017 1:25 am

Passive cant work out of the box without the setting the passive ports. Port 21 and 20 are used for standard FTP, which works fine. I only have a problem when I turn on passive. This isn't the first FTP I have set up, only the first on a Linux system. I have ran multiple FTP's on different Windows operating systems over the past 20 years. While I appreciate your input, but it is definitely wrong in this instance.

Now with PROFTPD, I set the passive port range in the config file (pretty much the same as VSFTPD) only it actually works for me with PROFTPD. When I said (out of the box) with PROFTPD, I meant all I had to do was set the setting.. I expect to do that. It immediately started working as I would have expected it would. At this point, I am just going to run with PROFTPD as I am pretty sure there is something wrong with VSFTPD.

Erdrick
Posts: 5
Joined: Sun Dec 17, 2017 7:26 pm

Re: vsftpd passive

Tue Dec 19, 2017 1:29 am

I should have added...

The listen setting is to listen on IPV4. Because IPV4 is the standard, it simply says IPV4. The other option is listen_ipv6 .. this is specifically for IPV6.. If Listen <> Yes .. the FTP doesn't work on IPV4

knute
Posts: 452
Joined: Thu Oct 23, 2014 12:14 am
Location: Texas
Contact: Website

Re: vsftpd passive

Tue Dec 19, 2017 3:50 pm

Erdrick wrote:
Tue Dec 19, 2017 1:25 am
Passive cant work out of the box without the setting the passive ports. Port 21 and 20 are used for standard FTP, which works fine. I only have a problem when I turn on passive.
Respectfully, you are wrong.
This isn't the first FTP I have set up, only the first on a Linux system.
That's clear.
I have ran multiple FTP's on different Windows operating systems over the past 20 years. While I appreciate your input, but it is definitely wrong in this instance.
Windows ain't Linux!
Now with PROFTPD, I set the passive port range in the config file (pretty much the same as VSFTPD) only it actually works for me with PROFTPD. When I said (out of the box) with PROFTPD, I meant all I had to do was set the setting.. I expect to do that. It immediately started working as I would have expected it would. At this point, I am just going to run with PROFTPD as I am pretty sure there is something wrong with VSFTPD.
You have my notes in the previous post on how to make vsftpd work with passive ftp.

Erdrick
Posts: 5
Joined: Sun Dec 17, 2017 7:26 pm

Re: vsftpd passive

Thu Dec 21, 2017 8:01 pm

First of all, standard mode (non-passive) ftp uses both ports 21 and 20. I already had this working. I even verified I was able to connect, download and upload files. I want to use passive to allow incoming data connections on specific ports that I can forward through my hardware firewall.

I am not using UFW, this is verified. I already tried adding ports to the iptable. I actually even tried allowing all incoming connections, which still didn't work. Keep in mind, I was trying to get passive to work on my local lan only, to start. I also setup iptables to allow everything on my local lan, still no go. I installed PROFTPD set my passive ports and it worked immediately. So you are telling me that passive on VSFTPD works differently than PROFTPD and every other FTP server I have ran? If that is the case, I don't want to use it because that would mean that is doesn't follow FTP standards

What you posted doesn't make sense. Maybe you can clarify.

You said I need to turn listen off. The listen setting activates listening for incoming connections on port 21. If I turn this off, the FTP will not work because it will not listen for new connections on port 21. Even VSFTPD own documentation states this, unless you are telling me their documentation is wrong. Even in passive mode, you still need port 21 to initiate the connection. But as I have stated, ports 20 & 21 were already working in standard mode. Nothing was blocking them. I was able to connect, download and upload.

You said I don't need the passive settings. How I would know what ports to forward through my hardware firewall? I have never heard of an FTP server that you didn't set the passive ports. I can't even say that statement without shaking my head in disbelief. It is like saying a house doesn't need a door.

I really appreciate your help but the mere fact that PROFTPD worked on the first try, with the exact same setting, mean that either VSFTPS doesn't work properly, the setting are mislabeled/confusing or isn't designed as most FTPs are designed. I spent 3 days trying to get passive to work. I read through all the documentation I could find for VSFTPD and read numerous forum posts with people having the same issue., Everything described the settings, just as PROFTPD settings are described, only PROFTPD works with the passive settings. Maybe the passive setting I have are wrong and the program is poorly documented. Obviously, passive should work. I doubt it is a programing error, maybe just the way they designed and labeled their settings doesn't make sense.

knute
Posts: 452
Joined: Thu Oct 23, 2014 12:14 am
Location: Texas
Contact: Website

Re: vsftpd passive

Thu Dec 21, 2017 8:49 pm

Erdrick wrote:
Thu Dec 21, 2017 8:01 pm
First of all, standard mode (non-passive) ftp uses both ports 21 and 20. I already had this working. I even verified I was able to connect, download and upload files. I want to use passive to allow incoming data connections on specific ports that I can forward through my hardware firewall.
In active ftp port 21 is the server's inbound port, port 20 is the outbound port and doesn't require opening a port through the firewall.
I am not using UFW, this is verified. I already tried adding ports to the iptable. I actually even tried allowing all incoming connections, which still didn't work. Keep in mind, I was trying to get passive to work on my local lan only, to start. I also setup iptables to allow everything on my local lan, still no go. I installed PROFTPD set my passive ports and it worked immediately. So you are telling me that passive on VSFTPD works differently than PROFTPD and every other FTP server I have ran? If that is the case, I don't want to use it because that would mean that is doesn't follow FTP standards
So you have a firewall you created with iptables? You might post that so we can see if that is blocking your connection.
What you posted doesn't make sense. Maybe you can clarify.

You said I need to turn listen off. The listen setting activates listening for incoming connections on port 21. If I turn this off, the FTP will not work because it will not listen for new connections on port 21. Even VSFTPD own documentation states this, unless you are telling me their documentation is wrong. Even in passive mode, you still need port 21 to initiate the connection. But as I have stated, ports 20 & 21 were already working in standard mode. Nothing was blocking them. I was able to connect, download and upload.
From the default vsftpd.conf file:

listen=NO
#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
listen_ipv6=YES
You said I don't need the passive settings. How I would know what ports to forward through my hardware firewall? I have never heard of an FTP server that you didn't set the passive ports. I can't even say that statement without shaking my head in disbelief. It is like saying a house doesn't need a door.
You didn't say anything about having a hardware firewall in front of your vsftpd. That greatly complicates things and since I don't know what the rest of your network looks like I hesitate to make a suggestion. If you need to get at ftp from the wild then you have more things to consider. But I would not use passive ftp if you have to get through a firewall especially if it is nated on the server side because of all the ports you have to open. I've been running vsftpd for 15 years and never set the passive ports. iptables takes care of all that for you and has for years.
I really appreciate your help but the mere fact that PROFTPD worked on the first try, with the exact same setting, mean that either VSFTPS doesn't work properly, the setting are mislabeled/confusing or isn't designed as most FTPs are designed. I spent 3 days trying to get passive to work. I read through all the documentation I could find for VSFTPD and read numerous forum posts with people having the same issue., Everything described the settings, just as PROFTPD settings are described, only PROFTPD works with the passive settings. Maybe the passive setting I have are wrong and the program is poorly documented. Obviously, passive should work. I doubt it is a programing error, maybe just the way they designed and labeled their settings doesn't make sense.
Then use proftpd.

Return to “Troubleshooting”