Setup FTP server CentOS 6 using vsftpd


Skenario 1: Setup Anonymous FTP server
-Install vsftpd
# yum -y install vsftpd

-Create folder for anonymous ftp sharing
# mkdir /home/ftp-anon

-Configure vsftpd.conf
# cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bak
# vi /etc/vsftpd/vsftpd.conf

anonymous_enable=YES
local_enable=YES
write_enable=NO
local_umask=022
#anon_upload_enable=YES
#anon_mkdir_write_enable=YES
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
#chown_uploads=YES
#chown_username=whoever
#xferlog_file=/var/log/xferlog
xferlog_std_format=YES
#idle_session_timeout=600
#data_connection_timeout=120
#nopriv_user=ftpsecure
#async_abor_enable=YES
#ascii_upload_enable=YES
#ascii_download_enable=YES
#ftpd_banner=Welcome to blah FTP service.
#deny_email_enable=YES
#banned_email_file=/etc/vsftpd/banned_emails
#chroot_local_user=YES
#chroot_list_enable=YES
#chroot_list_file=/etc/vsftpd/chroot_list
#ls_recurse_enable=YES
listen=YES
#listen_ipv6=YES
anon_root=/home/ftp-anon
anon_max_rate=2048000
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

-Start service & make run at boot
# service vsftpd start
# chkconfig vsftpd on

-Testing
Copy some folders/files to anonymous ftp folder in /home/ftp-anon/ then on web browser type ftp://ip_address_ftp_server and test download the files

 
Skenario 2: Setup FTP server with users login, anonymous can’t access ftp server, users with correct login can upload and download from ftp server

-Create ftp users directory and group:
# groupadd ftpusers
# mkdir /home/ftp-docs

-Make the directory read write to the ftp-users group
# chmod 770 /home/ftp-docs
# chown root:ftpusers /home/ftp-docs

-Add users, and make their default directory /home/ftp-docs
# useradd -g ftpusers -d /home/ftp-docs ftpuser1
# useradd -g ftpusers -d /home/ftp-docs ftpuser2
# useradd -g ftpusers -d /home/ftp-docs ftpuser3
# passwd ftpuser1
# passwd ftpuser2
# passwd ftpuser3

-Configure SSL/TLS (Optional)
# cd /etc/pki/tls/certs
# openssl req -x509 -nodes -newkey rsa:1024 -keyout /etc/pki/tls/certs/vsftpd.pem -out /etc/pki/tls/certs/vsftpd.pem
# chmod 600 vsftpd.pem

-Configure vsftpd.conf
# vi /etc/vsftpd/vsftpd.conf

anonymous_enable=NO
local_enable=YES
write_enable=YES

#Umask;0:read,write,execute;1:read,write;2:read,execute;3:read only;
#4:write,execute;5:write only;6:execute only;7:no permissions
local_umask=007
chmod_enable=YES
file_open_mode=0777
#anon_upload_enable=YES
#anon_mkdir_write_enable=YES
dirmessage_enable=YES
connect_from_port_20=YES
#chown_uploads=YES
#chown_username=whoever

#Options for log
xferlog_enable=YES
#xferlog_file=/var/log/xferlog
xferlog_std_format=NO
#see log in /var/log/vsftpd.log
log_ftp_protocol=YES

idle_session_timeout=600
#data_connection_timeout=120
#nopriv_user=ftpsecure
#async_abor_enable=YES
ascii_upload_enable=YES
ascii_download_enable=YES
#ftpd_banner=Welcome to test FTP service.
#deny_email_enable=YES
#banned_email_file=/etc/vsftpd/banned_emails

#Options users can only see their home directory
chroot_local_user=NO
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list

ls_recurse_enable=YES
listen=YES
#listen_ipv6=YES
#anon_root=/home/ftp-anon
#anon_max_rate=2048000
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
use_localtime=YES
# specify root directory(if don't specify, users' home directory become FTP home directory)
local_root=/home/ftp-docs
# Enable SSL(Comment these junk below if u pass configure SSL/TLS step)
require_ssl_reuse=NO
rsa_cert_file=/etc/pki/tls/certs/vsftpd.pem
ssl_enable=YES
force_local_data_ssl=YES
force_local_logins_ssl=YES

-Add chrooted users
# vi /etc/vsftpd/chroot_list

ftpuser1
ftpuser2
ftpuser3

-Start service & make run at boot
# service vsftpd start
# chkconfig vsftpd on

-Testing:
Access Ftp server from Windows host using FileZilla FTP Client to upload and download file..

 
References:
https://security.appspot.com/vsftpd/vsftpd_conf.html
http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch15_:_Linux_FTP_Server_Setup#.ULd1voZb7Qg
http://www.g-loaded.eu/2008/12/02/set-up-an-anonymous-ftp-server-with-vsftpd-in-less-than-a-minute/
http://www.server-world.info/en/note?os=CentOS_6&p=ftp&f=5

Leave a Reply

Your email address will not be published. Required fields are marked *