Welcome to Centmin Mod Community
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 Active Member

    917
    240
    43
    Oct 31, 2015
    Rijeka, Croatia
    Ratings:
    +388
    Local Time:
    9:43 AM
    Nginx 1.13.3
    MariaDB 10.1.24
    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

    30,144
    6,782
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,132
    Local Time:
    5:43 PM
    Nginx 1.13.x
    MariaDB 5.5
    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
    
     
    • Like Like x 1
  3. RoldanLT

    RoldanLT Well-Known Member

    3,899
    949
    113
    May 25, 2014
    Phillipines
    Ratings:
    +1,298
    Local Time:
    3:43 PM
    1.11
    10.2
    Or setup a cron :)
    Code (Text):
    */5 * * * * /bin/chown -R nginx:nginx /home/nginx/domains/
    
     
    • Like Like x 2
    • Winner Winner x 1
  4. Sunka

    Sunka Active Member

    917
    240
    43
    Oct 31, 2015
    Rijeka, Croatia
    Ratings:
    +388
    Local Time:
    9:43 AM
    Nginx 1.13.3
    MariaDB 10.1.24
    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 Active Member

    917
    240
    43
    Oct 31, 2015
    Rijeka, Croatia
    Ratings:
    +388
    Local Time:
    9:43 AM
    Nginx 1.13.3
    MariaDB 10.1.24
    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:
    9:43 AM
    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.
     
    • Like Like x 1
    • Informative Informative x 1
  7. eva2000

    eva2000 Administrator Staff Member

    30,144
    6,782
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,132
    Local Time:
    5:43 PM
    Nginx 1.13.x
    MariaDB 5.5
    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
     
    • Like Like x 1
  8. Sunka

    Sunka Active Member

    917
    240
    43
    Oct 31, 2015
    Rijeka, Croatia
    Ratings:
    +388
    Local Time:
    9:43 AM
    Nginx 1.13.3
    MariaDB 10.1.24
    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

    30,144
    6,782
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,132
    Local Time:
    5:43 PM
    Nginx 1.13.x
    MariaDB 5.5
    whichever one which command returns

    centos 6.7 returns /bin/chown while centos 7.x returns /usr/bin/chown
     
    • Like Like x 1
    • Informative Informative x 1