5.3.8. Install and configure ProFTPd

Instead of configuring FTP access, you can use connect via SFTP.

To connect to a server via FTP, you need to install and configure on the server special software — FTP server. One of the most popular and convenient FTP servers is ProFTPd.

Connect to the server via SSH or VNC, install ProFTPd and edit the configuration files. The procedure depends on the OS you are using.

  1. Install EPEL repository:
    yum install epel-release
  2. Install ProFTPd:
    yum install proftpd
  3. Open ports for FTP operations:
    firewall-cmd --permanent --add-port=20-21/tcp
    firewall-cmd --permanent --add-port=40900-40999/tcp 
    firewall-cmd --reload
  4. Enable ProFTPd to start at system startup and run it:
    systemctl enable proftpd
    systemctl start proftpd
  5. Change the ProFTPd configuration file.
  1. Install ProFTPd:
    apt-get install proftpd
  2. Change the ProFTPd configuration file.
  3. Execute command:
    echo "/bin/false" >> /etc/shells
  1. Install ProFTPd:
    emerge --ask net-ftp/proftpd
  2. Copy the configuration file (if it does not exist):
    cp /etc/proftpd/proftpd.conf.distrib /etc/proftpd/proftpd.conf
  3. Change the ProFTPd configuration file.
  4. Enable ProFTPd to start at system startup and run it:
    1. For OpenRC:
      rc-update add proftpd default 
      rc-service proftpd start
    2. For systemd:
      systemctl enable proftpd
      systemctl start proftpd
  1. Install ProFTPd:
    dnf -y install proftpd 
  2. Change the ProFTPd configuration file (located in /etc/proftpd.conf). At the end of the file, add the line:
    PassivePorts 21000 21020
  3. Enable ProFTPd to start at system startup and run it:
    systemctl enable proftpd
    systemctl start proftpd
  4. Configure SElinux (if you have it) and the firewall:
    setsebool -P ftp_home_dir=1
    setsebool -P allow_ftpd_full_access=1
    # Firewall
    firewall-cmd --permanent --add-port=21/tcp
    firewall-cmd --add-port=21000-21020/tcp --permanent
    firewall-cmd --reload

ProFTPd can use both virtual users and system users as users.

  1. Create an FTP user:
    useradd example -d /var/www --shell /bin/false --ingroup www-data
    • example — name of the FTP user.
    • /var/www — home directory of the FTP user.
    • www-data — group to which the web server or other app that will use the uploaded files belongs (www-data is the default group for the Apache web server).
  2. Grant the user permissions to edit files in the desired directories:
    chown example:www-data -R /var/www
    • example — created FTP user.
    • www-data — group to which the web server or other app that uses the uploaded files belongs (www-data is the default group for the Apache web server).
    • /var/www — directory for which permissions are changed (usually the directory with site files, by default /var/www).
  1. Edit the ProFTPd configuration file:
    nano /etc/proftpd/proftpd.conf

    Change the lines:

    • ServerName — server name.
    • ServerType — startup mode:
      • standalone — automatic startup at system startup (by default).
      • inetd — only manual startup.
    • # DefaultRoot — remove the # character at the beginning of the line. This parameter specifies access to the default directory. To specify default access to the user's directory, specify ~.
    • Add the line UseReverseDNS off before the line # Use this to jail all users in their homes (by default is line 34).
    • Check that the configuration file is correct:
      proftpd -t
  2. Restart ProFTPd:
    /etc/init.d/proftpd restart
Content

    Comments

    Roman P.
    А як налаштувати так, щоб залишались права на файли та папки користувача www-data:www-data, навіть, якщо я заходжу, умовно кажучи, під логіном ftpuser1? По при такому налаштуванні, створюються нові файли від імені ftpuser1:ftpuser1 і веб-сервер www-data:www-data їх вже не може відкрити і прочитати
    verliber
    Ви можете налаштувати директиви самого ProFTPD: UserOwner або GroupOwner для вказівки власника нових файлів\каталогів, але зверніть увагу, що користувач ftpuser1:ftpuser1 може втратити до них доступ. Краще використовувати ACL для налаштування доступів до каталогу, в рамках якого працюють ftp користувачі, дозволивши доступ до файлів, незалежно від їх власника, або додати користувача ftpuser1 до групи www-data, що можна поєднати з варіантом директив.

    Додамо цю інформацію до статті.