Settings up FTP

Initial Setup

Setup directory that will be root for ftp in this case it is /core/Interfaces

 mkdir -p /core/Interfaces

Install VSFTPD

yum install vsftpd 

Main configuration file for VSFTP is /etc/vsftpd/vsftpd.conf Here is what needs to be in it

[root@Dubactomcat vsftpd]# grep -v '^\s*$\|^\s*\#' /etc/vsftpd/vsftpd.conf
anonymous_enable=NO
local_enable=YES
virtual_use_local_privs=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=YES
listen_ipv6=NO
pam_service_name=vsftpd.virtual
userlist_enable=YES
tcp_wrappers=YES
allow_writeable_chroot=YES
userlist_file=/etc/vsftpd.userlist
userlist_deny=NO
user_sub_token=$USER
local_root=/core/Interfaces
chroot_local_user=YES
hide_ids=YES

You also need to create a list of users that will be allowed in this list is called /etc/vsftpd/userlist all it has its the user that will be allowed in

 [root@Dubactomcat etc]# cat vsftpd.userlist
ota_ftp

This user needs to exist in server and it will have nologin permissions

[root@Dubactomcat vsftpd]# id ota_ftp
uid=1007(ota_ftp) gid=1007(ota_ftp) groups=1007(ota_ftp)

[brindleyp@CRKTomCat scripts]$ grep ota_ftp /etc/passwd
ota_ftp:x:1007:1007::/var/ftp:/bin/nologin

You then need to create file that will contain the FTP user and its password /etc/vsftpd/virtualusers.txt

[root@Dubactomcat vsftpd]# cat virtualusers.txt
ota_ftp
Welcome99

this file needs to be converted into a DB before it can be used and its permissions need to be set

db_load -T -t hash -f /etc/vsftpd/virtualusers.txt /etc/vsftpd/virtualusers.db
chmod 600 /etc/vsftpd/virtualusers.db

This service relies on PAM for authentication need to create the pam service file vsftpd.virtual this file specifies where the ftp users list is

[root@Dubactomcat vsftpd]# cat /etc/pam.d/vsftpd.virtual
auth       required     pam_userdb.so db=/etc/vsftpd/virtualusers
account    required     pam_userdb.so db=/etc/vsftpd/virtualusers
session    required     pam_loginuid.so

that should be it. Now enable and start vsftpd

systemctl enable vsftpd
systemctl start vsftpd