Want to subscribe to topics you're interested in?
Become a Member

Add new user to pure-ftpd virtual ftp

Discussion in 'Install & Upgrades or Pre-Install Questions' started by Sunka, Nov 23, 2015.

  1. Sunka

    Sunka Well-Known Member

    1,150
    325
    83
    Oct 31, 2015
    Pula, Croatia
    Ratings:
    +525
    Local Time:
    12:19 PM
    Nginx 1.17.9
    MariaDB 10.3.22
    When created new host, new ftp user for that domain is created too, and have access to /home/nginx/domains/domain.com/ and below.


    How to create another user which have access to /home/nginx/domains/domain.com/ and below like default one?

    Regarding folders that root user created inside domain.com folder, how to give write permission to this two users?
     
  2. eva2000

    eva2000 Administrator Staff Member

    54,935
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,812
    Local Time:
    9:19 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    as per pure-pw commands outlined at Beta Branch - Centmin Mod .08 beta + pure-ftpd virtual FTP user support | Centmin Mod Community for setting up existing nginx vhosts with pure-ftpd virtual ftp users

    create your FTP username via command below which will lock and jail the YOURFTPUSERNAME to directory path specified by -d /home/nginx/domains/YOURDOMAINVHOST. So you can also lock specific virtual FTP users to other directory paths to if you want.
    Code (Text):
    pure-pw useradd YOURFTPUSERNAME -u nginx -g nginx -d /home/nginx/domains/YOURDOMAINVHOST
    service pure-ftpd restart
    



    as per getting started guide step 2 Getting Started Guide - CentminMod.com LEMP Nginx web stack for CentOS

    Whenever you completed uploading new files, you'd need to give them correct user and group permissions within SSH window as root user type:
    Code (Text):
    chown -R nginx:nginx /home/nginx/domains/newdomain.com/public
    

    You do not need to do this will files created via PHP-FPM or Nginx, i.e. if you use Wordpress and used Wordpress admin to add a new Wordpress plugin, the plugin will automatically have nginx user and group permissions as it was processed by PHP-FPM.

    To verify the files and directories are with nginx user and group permissions, use command
    Code (Text):
    ls -lah directorypath
    

    i.e.
    Code (Text):
    ls -lah /home/nginx/domains/newdomain.com/public
    
    total 36K
    drwxr-sr-x 2 nginx nginx  151 Aug 11 05:24 .
    drwxr-sr-x 6 nginx nginx   56 Aug 11 05:24 ..
    -rw-r--r-- 1 nginx nginx 1.6K Aug 11 05:24 403.html
    -rw-r--r-- 1 nginx nginx 1.6K Aug 11 05:24 404.html
    -rw-r--r-- 1 nginx nginx 2.1K Aug 11 05:24 500.html
    -rw-r--r-- 1 nginx nginx 2.1K Aug 11 05:24 502.html
    -rw-r--r-- 1 nginx nginx 2.2K Aug 11 05:24 503.html
    -rw-r--r-- 1 nginx nginx 2.1K Aug 11 05:24 504.html
    -rw-r--r-- 1 nginx nginx 2.2K Aug 11 05:24 50x.html
    -rw-r--r-- 1 nginx nginx 1.2K Aug 11 05:24 index.html
    -rw-r--r-- 1 nginx nginx 2.2K Aug 11 05:24 maintenance.html
    
     
  3. rdan

    rdan Well-Known Member

    5,447
    1,408
    113
    May 25, 2014
    Ratings:
    +2,201
    Local Time:
    7:19 PM
    Mainline
    10.2
    Or setup a cron :)
    Code (Text):
    */5 * * * * /bin/chown -R nginx:nginx /home/nginx/domains/
    
     
  4. Sunka

    Sunka Well-Known Member

    1,150
    325
    83
    Oct 31, 2015
    Pula, Croatia
    Ratings:
    +525
    Local Time:
    12:19 PM
    Nginx 1.17.9
    MariaDB 10.3.22
    why /bin/ @RoldanLT?

    Is this one bellow wrong?
    Code:
    */5 * * * * chown -R nginx:nginx /home/nginx/domains/pijanitvor.com/public
    And this one bellow will be OK to add to crontab -e?

    Code:
    */5 * * * * /bin/chown -R nginx:nginx /home/nginx/domains/pijanitvor.com/public
     
  5. Sunka

    Sunka Well-Known Member

    1,150
    325
    83
    Oct 31, 2015
    Pula, Croatia
    Ratings:
    +525
    Local Time:
    12:19 PM
    Nginx 1.17.9
    MariaDB 10.3.22
    So it will be something like this (user: tester):
    Code (Text):
    pure-pw useradd tester -u nginx -g nginx -d /home/nginx/domains/pijanitvor.com/public
    service pure-ftpd restart
    

    What about: pure-pw mkdb

    What about password?
    Code:
    pure-pw passwd FTPUSERNAME
    pure-pw mkdb
     
    Last edited: Nov 24, 2015
  6. Ahmad

    Ahmad Active Member

    209
    80
    28
    Apr 13, 2015
    Ratings:
    +150
    Local Time:
    12:19 PM
    1.9.9
    10.1.10
    It is not really wrong but it is better to use full path to avoid issues.

    Correct
    You use
    Code:
    pure-pw passwd FTPUSERNAME
    to set the password for FTPUSERNAME and after that you run
    Code:
    pure-pw mkdb
    to write the changes to the correct DB.
     
  7. eva2000

    eva2000 Administrator Staff Member

    54,935
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,812
    Local Time:
    9:19 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    either one with or without /bin but full path to the chown command is safer to ensure it runs (full path of any command can be found via which cmd so for chown, which chown)

    sorry technically you can do just
    Code (Text):
    pure-pw useradd tester -u nginx -g nginx -d /home/nginx/domains/pijanitvor.com/public
    pure-pw mkdb

    according to https://download.pureftpd.org/pub/pure-ftpd/doc/README.Virtual-Users
    That's for changing password, the useradd command should prompt for you to add a password
     
  8. Sunka

    Sunka Well-Known Member

    1,150
    325
    83
    Oct 31, 2015
    Pula, Croatia
    Ratings:
    +525
    Local Time:
    12:19 PM
    Nginx 1.17.9
    MariaDB 10.3.22
    Code:
    [root@tvor-ocean ~]# which chown
    /usr/bin/chown
    Which one of this two:

    Code:
    */5 * * * * /bin/chown -R nginx:nginx /home/nginx/domains/pijanitvor.com/public
    or

    Code:
    */5 * * * * /usr/bin/chown -R nginx:nginx /home/nginx/domains/pijanitvor.com/public
     
  9. eva2000

    eva2000 Administrator Staff Member

    54,935
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,812
    Local Time:
    9:19 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    whichever one which command returns

    centos 6.7 returns /bin/chown while centos 7.x returns /usr/bin/chown