FTP file Server on Redhat Linux
FTP file Server on Redhat Linux
In this short config we will install FTP file Server on RHEL7 Linux using vsftpd. We will stick to the default vsftpd configuration which enables user accounts on our
existing RHEL7 Linux system to login via FTP from a remote location, list and transfer files. Let's begin by the installation:
To install FTP server on Redhat 7 Linux we can use either tftp-server or vsftpd daemon. In this guide we use vsftpd:
To make the FTP service startup persistent after system reboot use:
ln -s '/usr/lib/systemd/system/vsftpd.service' '/etc/systemd/system/multi-user.target.wants/vsftpd.service'
Check and see whether port 21 is open. Do not worry if you do not see IPv4 of this port open as its IPv6 bind.
We also need to open firewall port otherwise we will see a following error message when we try to connect:
ftp>
# 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.
Allow the port (TCP 40000) in iptables in order to connect ftp server over the network.
# firewall-cmd --reload
To open a port 21 on Redhat 7 linux use the following commands. The port we remain open to public even after system restart:
success
success
At this point we should be able to connect from a remote host where the IP address of our FTP service is 10.1.1.110:
$ ftp 10.1.1.110
Password:
ftp>
The next configuration we need to perform is to enable iptables module ip_conntrack_ftp otherwise we will see a following error message query our FTP server
after successful login:
ftp> ls
ftp>
See this page for a more permanent solution on how to load ip_conntrack_ftp module after reboot.
The last configuration we need to perform is to enable selinux FTP context for user directories currently on the system otherwise we will not be able to read/write
or transfer any files between FTP server and FTP client:
To enable selinux FTP home directory context to allow read and write commands. For this we use setsebool command:
The above will set selinux FTP home directory context permanently -P after reboot.
Now you have your FTP server setup. For more configuration options see the main vsftpd FTP server configuration file /etc/vsftpd/vsftpd.conf. When making a
changes to the configuration file make sure to apply them by restarting FTP service: