Enable Passive Mode in FTP on CentOS 7 / RHEL 7 for FileZilla and WinSCP
In my last post, I have shown you how to install and configure FTP Server (vsftpd) on CentOS 7 / RHEL 7. While testing the FTP server using FileZilla (i am using LinuxMint), I got the following error.
Error: The data connection could not be established: EHOSTUNREACH - No route to host Error: Connection timed out Error: Failed to retrieve directory listing
After a lot of searches, I found FileZilla uses passive mode as a default file transfer mode; but the vsftpd is configured to use active mode by default.
We have two options,
- Configure FileZilla to use active mode.
- Configure FTP server in passive mode.
Use any one method.
Configure FileZilla to use active mode
In this case, you do not require to modify vsftpd server. Change FileZilla transfer mode from passive to active.
In Linux Mint, View >> Settings >> FTP, Select Transfer Mode as Active
Configure FTP server in passive mode
In this case, you do not require to modify FileZilla. Change vsftp transfer mode from active to passive, edit the configuration file of FTP server
# vi /etc/vsftpd/vsftpd.conf
Add the following lines at the end of the file.
pasv_enable=Yes pasv_max_port=40000 pasv_min_port=40000
Restart the service.
# systemctl restart vsftpd.service
Allow the port (TCP 40000) in iptables to connect FTP server over the network.
# firewall-cmd --permanent --add-port=40000/tcp # firewall-cmd --reload
Now access FTP using FileZilla, you can see in the message; it is using passive mode for transferring the file as the FTP server supports it.