Sunday, June 17, 2012

Ftp Access to /var/www/html for website editing [CentOS/RHEL + Vsftpd]

1. Create a group for website users , say webgroup   # groupadd webgroup
2. give them proper permissions  : chown -R root:webgroup /var/www/html
3.chmod g+s  /var/www/html    {this will help if a user "x" creates a file/dir then it will be owned by him , so set a SETGID bit to the parent directory so that any new file by default have group id as webgroup}
4. chmod 770 /var/www/html
5. usermod -aG webgroup apache


How to Set VSFTPD

#yum install vsftpd
# service vsftpd start
#chkconfig vsftpd on
# netstat -a | grep ftp


Contents of vsftpd.conf
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=002
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
ftpd_banner=Hello world
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list
pam_service_name=vsftpd
userlist_enable=YES
listen=YES
tcp_wrappers=YES


Contents of vsftpd.chroot_list

webftpuser


contents of : cat /etc/pam.d/vsftpd
#%PAM-1.0
auth       required     pam_listfile.so item=user sense=deny file=/etc/vsftpd.ftpusers onerr=succeed
auth       required     pam_stack.so service=system-auth
auth       required     pam_shells.so
account    required     pam_stack.so service=system-auth
session    required     pam_stack.so service=system-auth






2 comments:

  1. #yum install vstpd

    change to:

    #yum install vsftpd

    ReplyDelete
  2. Who can i create a new FTP user ?
    I add one with # useradd -g webgroup webmaster
    And create a password with # passwd webmaster

    But i cant login with Filezilla or over Firefox.

    ReplyDelete