Step 1: Install vsftpd
Warning: FTP data is insecure; traffic is not encrypted, and all transmissions are clear text (including usernames, passwords, commands, and data). Consider securing your FTP connection with SSL/TLS.
As a matter of best practice we’ll update our packages:
yum -y update
Then let’s install vsftpd and any required packages:
yum -y install vsftpd
Step 2: Configure vsftpd
The
vsftpd
RPM installs the daemon (/usr/sbin/vsftpd
), its configuration and related files, as well as FTP directories onto the system.The following lists the files and directories related to
vsftpd
configuration:
-
/etc/rc.d/init.d/vsftpd
— The initialization script (initscript) used by thesystemctl
command to start, stop, or reload vsftpd. Refer to Starting and Stoppingvsftpd
” for more information about using this script.
Restart the vsftpd service:systemctl restart vsftpd
Then set the vsftpd service to start at boot:systemctl enable vsftpd
-
/etc/pam.d/vsftpd
— The Pluggable Authentication Modules (PAM) configuration file forvsftpd
. This file specifies the requirements a user must meet to login to theFTP
server. For more information on PAM, refer to the Using Pluggable Authentication Modules (PAM) chapter of the Fedora 17 Managing Single Sign-On and Smart Cards guide.
/etc/vsftpd/vsftpd.conf
— The configuration file for vsftpd. Refer to “ vsftpd
Configuration Options” for a list of important options contained within this file.
Configuration file for vsftpd:
vim /etc/vsftpd/vsftpd.conf
Each directive is on its own line within the file and follows the following format:
directive=value
1. For each directive, replace
directive
with a valid directive and value
with a valid value.Do not use spaces
There must not be any spaces between the
directive
, equal symbol, and the value
in a directive.2. Daemon Options
The following is a list of directives which control the overall behavior of the
vsftpd
daemon.-
listen
— When enabled,vsftpd
runs in stand-alone mode. Fedora sets this value toYES
. This directive cannot be used in conjunction with thelisten_ipv6
directive.The default value isNO
. -
listen_ipv6
— When enabled,vsftpd
runs in stand-alone mode, but listens only toIPv6
sockets. This directive cannot be used in conjunction with thelisten
directive.The default value isNO
. -
session_support
— When enabled,vsftpd
attempts to maintain login sessions for each user through Pluggable Authentication Modules (PAM). For more information, refer to the Using Pluggable Authentication Modules (PAM) chapter of the Red Hat Enterprise Linux 6 Managing Single Sign-On and Smart Cards and the PAM man pages. . If session logging is not necessary, disabling this option allowsvsftpd
to run with less processes and lower privileges.The default value isYES
.
3. Permission:
pam_service_name
Disallow anonymous, unidentified users to access files via FTP; change the anonymous_enable setting to NO:anonymous_enable=NO
- Allow local uses to login by changing the local_enable setting to YES:
local_enable=YES - If you want local user to be able to write to a directory, then change the write_enable setting to YES:
write_enable=YES - Local users will be ‘chroot jailed’ and they will be denied access to any other part of the server; change the chroot_local_user setting to YES:
chroot_local_user=YES
- Specifies a comma-delimited list of
FTP
commands allowed by the server. All other commands are rejected.
cmds_allowed
-
pam_service_name
— Specifies the PAM service name forvsftpd
.The default value isftp
.
Note, in Fedora, the value is set tovsftpd
. The default value isNO
. Note, in Fedora, the value is set toYES
. -
userlist_deny
— When used in conjunction with theuserlist_enable
directive and set toNO
, all local users are denied access unless the username is listed in the file specified by theuserlist_file
directive. Because access is denied before the client is asked for a password, setting this directive toNO
prevents local users from submitting unencrypted passwords over the network.The default value isYES
. -
userlist_enable
— When enabled, the users listed in the file specified by theuserlist_file
directive are denied access. Because access is denied before the client is asked for a password, users are prevented from submitting unencrypted passwords over the network.The default value isNO
, however under Fedora the value is set toYES
. -
userlist_file
— Specifies the file referenced byvsftpd
when theuserlist_enable
directive is enabled.The default value is/etc/vsftpd/user_list
and is created during installation.
-
/etc/vsftpd/ftpusers
— A list of users not allowed to log intovsftpd
. By default, this list includes theroot
,bin
, anddaemon
users, among others. -
/etc/vsftpd/user_list
— This file can be configured to either deny or allow access to the users listed, depending on whether theuserlist_deny
directive is set toYES
(default) orNO
in/etc/vsftpd/vsftpd.conf
. If/etc/vsftpd/user_list
is used to grant access to users, the usernames listed must not appear in/etc/vsftpd/ftpusers
. -
/var/ftp/
— The directory containing files served byvsftpd
. It also contains the/var/ftp/pub/
directory for anonymous users. Both directories are world-readable, but writable only by theroot
user.
Step 3: Allow vsftpd Through the Firewall
Allow the default FTP port, port 21, through firewalld:
firewall-cmd --permanent --add-port=21/tcp
And reload the firewall:
firewall-cmd --reload