Friday, April 13, 2012

Configure FTP server on Fedora 16/17

This post is about the configuration of FTP server for the specified users.

$ sudo yum install vsftpd
$ sudo nano /etc/vsftpd/vsftpd.conf

anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
anon_upload_enable=NO
anon_mkdir_write_enable=NO
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/vsftpd.log
xferlog_std_format=YES
ftpd_banner=Welcome to FTP server!!
chroot_local_user=YES
listen=NO
log_ftp_protocol=YES
max_per_ip=5 # Max number of allowed connections per IP Address.
max_clients=5 # Max number of different IP Addressed which are allowed to connect.
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES


$ sudo systemctl enable vsftpd.service
$ sudo systemctl start vsftpd.service


$ sudo groupadd ftp-users

# Add you local user to ftp-users group
$ sudo usermod -a -G ftp-users local_user

# Create ftp folders
$ sudo mkdir -p /home/ftpusr/upload

# Make your local user a root user for ftp users
$ sudo chown local_user:ftp-users /home/ftpusr -R

# Give to your local user all permissions
$ sudo chmod 750 /home/ftpusr

# Give to ftp users "rwx" permissions only for "upload" folder
$ sudo chmod 770 /home/ftpusr/upload/

# Add ftp user
$ sudo useradd -M -g ftp-users ftpusr
$ sudo passwd ftpusr


# Test your ftp server
$ ftp your_ftp_ip_address

# If error '500 OOPS: cannot change directory' appeared then go to selinux and see decision or run:
$ sudo setsebool -P allow_ftpd_full_access 1

# To mount/unmount folders to ftp use these commands:
$ sudo mount --bind source_folder ftp_folder
# or
$ sudo mount --rbind source_folder ftp_folder
$ sudo umount ftp_folder

2 comments:

  1. Please help when i try follow this show message error:
    Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled)
    Active: failed (Result: exit-code) since Wed, 12 Sep 2012 15:19:26 +0700; 55s ago
    Process: 8539 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=2)
    CGroup: name=systemd:/system/vsftpd.service

    Sep 12 15:19:26 ns1 vsftpd[8539]: warning: can't get client address: Socket operation on non-socket

    ReplyDelete
    Replies
    1. you open vsftpd.conf and you add # before LISTEN as:
      # When "listen" directive is enabled, vsftpd runs in standalone mode and
      # listens on IPv4 sockets. This directive cannot be used in conjunction
      # with the listen_ipv6 directive.
      # listen=NO

      if you don't add # before listen=NO then you can config listen=YES, because it run don't standalone, you can search google to know more :)

      Delete