vsftpd ftp file server setup

yum install vsftpd ftp -y

chkconfig vsftpd on
sestatus              # to check selinux status
[root@web vsftpd]#  getsebool -a | grep ftp  
allow_ftpd_anon_write --> off
allow_ftpd_full_access --> off
allow_ftpd_use_cifs --> off
allow_ftpd_use_nfs --> off
ftp_home_dir --> off
ftpd_connect_db --> off
ftpd_use_passive_mode --> off
httpd_enable_ftp_server --> off
tftp_anon_write --> off

you need to enable ftp_home_dir => on

# setsebool -P ftp_home_dir=1   

vim /etc/vsftpd/vsftpd.conf

anonymous_enable=NO
chroot_local_user=YES
chroot_list_enable=NO
chroot_list_file=/etc/vsftpd/chroot_list 
 
listen=YES
#listen_ipv6=YES  this will disable ipv6 listening
#current version doesnt support the vsftp listening on ipv4 and ipv6 simultaneously.
 
And lets configure vsftpd to be able to chroot(commonly referred to as 
jailing or jail) users to their home directories for security and 
privacy:
 
 
  • Also, lock down vsftpd to a predictable port range. (By default, vsftpd runs in passive mode and will choose a port between 1024-65535). Add the following:
pasv_min_port=3000
pasv_max_port=3050

  • Create the chroot_list file so you do not get an error when restarting:
sudo touch /etc/vsftpd/chroot_list

For RHEL6

iptables -I INPUT -m tcp -p tcp --dport 21 -j ACCEPT
iptables -I INPUT 1 -p tcp --dport 3000:3050 -j ACCEPT
 
For RHEL5 
 
iptables -I RH-Firewall-1-INPUT 1 -p tcp --dport 3000:3050 -j ACCEPT
iptables -I RH-Firewall-1-INPUT -m tcp -p tcp --dport 21 -j ACCEPT 


Setup user for ftp with no login

# useradd test
    # passwd test
 
usermod -s /sbin/nologin test
 
 
Making the softlink work !!!!!!
 
we create a symbolic link inside user’s folder to point to the music folder:
 
ln -s /tmp/harddisk/music /tmp/harddisk/ftp_pvt/user/music 


It seems like everything is okay. As long as the permissions for the folder music grants access for the right users

Instead of copying whole content use mount

  mkdir /tmp/harddisk/ftp_pvt/user/music



 
 
Mount the folder you want user to access using the bind option  
 
  mount --bind /tmp/harddisk/music /tmp/harddisk/ftp_pvt/user/music
 

 Consider "/realdata/dir   /virtual/dir  none default,bind 0 0" in 
/etc/fstab to make the "mount -B" available on reboot as well (perhaps 
less obscure than "/etc/rc.local"). Note: don't bother looking into hard
 links, since they will not link directories, and will not file systems.

No comments:

Post a Comment