LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-14-2015, 09:16 PM   #1
JockVSJock
Senior Member
 
Registered: Jan 2004
Posts: 1,420
Blog Entries: 4

Rep: Reputation: 164Reputation: 164
VSFTPD Connection Times Out, Then Setting Passive Mode Works, Why?


I'm testing vsftpd in a VM environment with various version of RHEL.

I'm trying to log in from a client to a vsftp server as anonymous, and I can log in, however when I run ls to list files on the vsftpd server, I continue to get:

Code:
ftp> ls
227 Entering Passive Mode (192,168,122,55,220,105)
ftp: connect: Connection timed out
Not sure why, and Googling around, I find a very helpful thread on Linuxquestions.org:
https://www.linuxquestions.org/quest...nnects-903987/

I do what they recommend:

- open ports on iptables 50000-51000

- in /etc/vsftpd/vsftpd.conf, I add the following:

Code:
pasv_enable=yes 
pasv_max_port=51000
pasv_min_port=50000 
port_enable=YES 
pasv_address=192.168.122.50
Restart vsftpd, however it tells me there is a binary error. So I go back to that conf file and comment out the pasv_enable, port_enable and pasv_address. Restart it and it works. I am able to log in as user anonymous, and browse /var/ftp and copy files down to my local server.

The thing is that I'm not understanding the why? This is called passive mode and why when enabling this on iptables, along with making entries under /etc/vsftpd/vstpd.conf, why it worked?
 
Old 11-14-2015, 11:01 PM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
pasv _enable and port_enable are on by default. Most likely, the pasv_address line also reflects the default. So, commenting them out won't change anything.

I do wonder about this binary error. What.'s the precise error message, and how do you get it?

The reason why ftp failed originally is the firewall blocking the ports used for data transfer. These ports are determined by the vsftpd on the fly, so that it's impossible to predict them and to open them in your firewall. The pasv_min_port and pasv_max_port clauses make them predictable.

A (better?) different way to get through the firewall is not changing the vsftpd config, but adding an iptables rule that uses the ip_conntrack_ftp module, which is able to detect the port the vsftpd sets up for data transfer.
 
Old 11-15-2015, 08:54 AM   #3
JockVSJock
Senior Member
 
Registered: Jan 2004
Posts: 1,420

Original Poster
Blog Entries: 4

Rep: Reputation: 164Reputation: 164
Quote:
Originally Posted by berndbausch View Post
pasv _enable and port_enable are on by default. Most likely, the pasv_address line also reflects the default. So, commenting them out won't change anything.
I'm not sure about this. I had to add lines to /etc/vsftpd/vsftpd.conf and then it worked, along with the right iptables entries. How does one know that vsftpd is set to passive?

Quote:
Originally Posted by berndbausch View Post
But adding an iptables rule that uses the ip_conntrack_ftp module, which is able to detect the port the vsftpd sets up for data transfer.
A couple of searched found this for setting up passive mode ftp via iptables:

http://blogs.reliablepenguin.com/201...-with-iptables

When I searched /etc/sysconfig/iptables-config, I don't see that entry in the current file.

I've also looked thru the various man pages for vsftpd and see a few other threads here at Linuxquestions and to me it seems that the documentation for vsftpd seems to be lacking in some areas.

thanks
 
Old 11-15-2015, 07:14 PM   #4
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by JockVSJock View Post
I'm not sure about this. I had to add lines to /etc/vsftpd/vsftpd.conf and then it worked, along with the right iptables entries. How does one know that vsftpd is set to passive?
RTFM http://linux.die.net/man/5/vsftpd.conf.
Quote:
pasv_enable
Set to NO if you want to disallow the PASV method of obtaining a data connection.
Default: YES
Quote:
Originally Posted by JockVSJock View Post
A couple of searched found this for setting up passive mode ftp via iptables:

http://blogs.reliablepenguin.com/201...-with-iptables

When I searched /etc/sysconfig/iptables-config, I don't see that entry in the current file.
It's not in iptables-config because neither you nor Red Hat put it there. By default, Red Hat closes all ports except for the secure shell.

If you don't trust the above link (judging from a superficial glance, it looks correct), perhaps there is documentation at the source - netfilter.org.

Quote:
Originally Posted by JockVSJock View Post
I've also looked thru the various man pages for vsftpd and see a few other threads here at Linuxquestions and to me it seems that the documentation for vsftpd seems to be lacking in some areas.
Better raise this to the author https://security.appspot.com/vsftpd.html.

Last edited by berndbausch; 11-15-2015 at 07:21 PM.
 
Old 11-16-2015, 01:08 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
This is good background reading http://slacksite.com/other/ftp.html
 
  


Reply

Tags
iptables, passive mode, vsftpd



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
VSFTPD - Passive mode refused hectorharvey Linux - Server 10 04-20-2012 04:31 PM
vsftpd with port 2021 not going to passive mode jjjj12212 Linux - Software 6 02-13-2012 01:14 PM
VSFTPD question...active/passive mode lapzlinux Linux - Networking 4 08-06-2011 01:54 AM
Vsftpd Entering passive mode pramka SUSE / openSUSE 1 07-18-2008 07:20 PM
Problem with vsftpd and passive mode 0001001 Linux - Server 1 09-12-2006 07:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration