Enable Passive Mode in FTP on CentOS 7 / RHEL 7 for FileZilla and WinSCP
In my last post, i have showed you how to install and configure vdftp on CentSO 7 / RHEL 7. While testing the ftp using FileZilla (i am using LinuxMint), i got a 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 search, i found FileZilla uses passive mode as a default file transfer mode; but the vsftp 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 vsftp 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 in order 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 file as the ftp server supports it.