proFTPd - Create individual directories for each user account

This post explains how to modify the proFTPd Administrator tool to make the create users tool actually create individual directories for each account that is created.


Requirements

This feature is designed to work from within the admin web interface so the following has to be installed:

Configuration

In the config file you can set a script to run every time a user is created (a sample script is included in the misc/user_create subfolder).
NoteNote
When we refer to this script in the configuration files, we have to include the absolute path. This document assumes that the proFTPd Administrator tool has been installed in /usr/share/proftpd_admin/.

Running the script to alter permissions and creating home directories requires root-access from the script. We will use the sudo tool to accomplish this.

  1. Check if sudo is installed:
    yum install sudo
  2. The file /etc/sudoers, has the rules that users have to follow when using sudo command. Edit the sudoers file:
    nano /etc/sudoers
    and add the following few lines:
    # Cmnd alias specification	
    Cmnd_Alias CREATE_USER = /usr/share/proftpd_admin/misc/user_script/create_user.sh	
    
    # User privilege specification	
    nobody ALL=(ALL) NOPASSWD: CREATE_USER
  3. Ensure proFTPd-admin includes the create_user script. Edit include_config.php:
    nano /usr/share/proftpd_admin/include_config.php
    add the following line to the end of the $ config ... statements at the top of the file:
    $config_createuser_command = "sudo /usr/share/proftpd_admin/misc/user_script/create_user.sh";
  4. Edit the create_user.sh to create home directory and setup correct user and group ownerships. (They are included in the create_user_example.sh script):
    cd /usr/share/proftpd_admin/misc/user_script/
    mv create_user.sh create_user_old.sh
    cp create_user_example.sh create_user.sh
  5. Now check the create_user.sh file:
    nano create_user.sh
    and ensure the file contains the following:
    #!/bin/bash	
    USER=$1	
    USER_ID=$2	
    GROUP_ID=$3	
    
    mkdir -p /ftp/$USER	
    chown $USER_ID.$GROUP_ID /ftp/$USER
  6. Ensure the security hasn't been compromised by running the following commands:
    chown -R root.root /usr/share/proftpd_admin/misc/user_script	
    chmod 700 -R /usr/share/proftpd_admin/misc/user_script

References

No comments:

Post a Comment