How add ftp users to folder or Apache server?
In this example we will create ftp group , ftp user and add it to the new or existing folder for ftp.
Step 1: If we already have group then we can skip this or lets start by creating a group, and lets call it ftpgroup
$ groupadd ftpgroup
Step 2: Create a user called ftpuser and add it to the group and also assign it with the folder. If folder is not assign default folder will be assigned which is normally /home/username
$ useradd userftp -p your-password -g ftpgroup -d /home/ftpfolder -s /bin/false
Normally ftp users dont need shell access so -s /bin/false.
Step 3: Set ownership.
chown ftpuser:ftpgroup /home/ftpuser
And you are done.
If we need more user to be added to already existing ftp folder then we can do as follows:
Add new user to existing ftp group:
$ useradd newftpuser -p your-password -g gtpgroup -d /home/ftpfolder -s bin/false
Note: we can modify user anytime with the usermod eg:
$ usermod - d /home/differentlocation
When we add new user to the group, we need to logout and login to the system, otherwise new user will not able to do ftp. If we dont want to logout/login then we can run following command to the folder.
chmod -R ugo+rw /home/ftpfolder
Extra: Limiting ftp users to their permitted folders:
To limit ftp users not able to go to top level folder we can do..sdfsdfdsf
if ftp server is vsftpd then make you have following un -commented or set.
chroot_local_user = yes
local_enable = Yes
and don’t forget to restart
service vsftpd restart
FTP users for web server like Apache:
If you are creating ftp for web users then make user user group is also apache else files uploaded by users will not be run by apache. So we can add multiple group to the users as follows:
usermod -a -G apache,group2 ftpuser
This step should work, but still you may not able to edit/create files because
When adding a user to a new group, that won’t be applied in any currently-running processes, only new ones. You need to log out and then log back in.
To fix this you can either logout and login or do the following command for your directory.
chmod -R ugo+rw sit3 this will give access to the group / user to read /write to the folder.