Setting Up FTP on CentOS 5.3

Install VSFTPD
yum -y install vsftpd
vim /etc/vsftpd/vsftpd.conf
anonymous_enable=NO // line 12: NO is no anonymous YES, you must set home folder for anonymous access
ascii_upload_enable=YES // line 79: make valid
ascii_download_enable=YES  (permit ascii mode transfer)
ls_recurse_enable=YES    // line 102: make valid
use_localtime=YES        // use local time
/etc/rc.d/init.d/vsftpd start
chkconfig vsftpd on //set ftp to autostart
Create a user group:
# groupadd ftp-users
Add users, and make their default directory /home/www/[account]. Make sure that each directory exist prior to sending these commands:
mkdir /home/www
mkdir /home/www/dragoncoin
mkdir /home/www/cafecenter
mkdir /home/www/ocgold
Create users / group on local system + permission:
useradd -g apache -d /home/www/dragoncoin dragoncoin
useradd -g apache -d /home/www/cafecenter cafecenter
useradd -g apache -d /home/www/ocgold ocgold
passwd dragoncoin
passwd ocgold
passwd cafecenter
——– Optional, In the event that users belong to other groups —-
usermod -g apache dragoncoin
usermod -g apache cafecenter
usermod -g apache ocgold
Set ownership for each account:
chmod 750 /home/www
chown root:apache /home/www
chown -R dragoncoin:apache /home/www/dragoncoin
chown -R cafecenter:apache /home/www/cafecenter
chown -R ocgold:apache /home/www/ocgold
Root folders for each user upon FTP logon:
usermod -d /home/www/dragoncoin dragoncoin
usermod -d /home/www/cafecenter cafecenter
usermod -d /home/www/ocgold ocgold

Optional: Create a link from the anon_ftpuser’s home folder to /var/www/public

ln -s /var/www/public /home/share/PublicFTP
Check Home Directory
Does the user’s home directory even exist? Check /etc/passwd for the current home directory for the user and see what’s set:
# grep someuser /etc/passwd
In this case, does /var/www/someuser exist? If it doesn’t, fix that and then move onto the next solution if you’re still having problems
File/Directory Permissions
Be sure that the user that you are logging in as actually has permissions to be in the directory. This affects users that have home directories of /var/www/html because the execute bit normally isn’t set for the world on /var/www or /var/www/html. Make sure that the appropriate permissions and ownerships are set, and this should help eliminate the issue.
If SELINUX is rearing its ugly head on the server, this can be a problem. Check your current SELINUX status and disable it if necessary:
# setenforce
# setenforce 0
Try to login over FTP again and you should have a success. If you want to turn off SELINUX entirely, adjust /etc/sysconfig/selinux (RHEL4) or /etc/selinux/config (RHEL5).
Here is another fix for the ftp issue with home directories, in case you cant turn selinux off:
setsebool -P ftp_home_dir 1
service vsftpd restart

Leave a Reply

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