Give FTP User access to specific directory in Linux

To create FTP user through SSH you would need to follow below mentioned steps:

1. Login as root through SSH.

2. Next add the user account you want using the 'useradd' command

useradd <username>

3. Now create a special group for that user.

groupadd <groupname>

4. Now to add the user to the group

gpasswd -a <username> <groupname>

These commands are non-standard but available on most popular distributions. If not, then you can
try editing /etc/group using your favorite text editor.

5. Change the group ownership of the special directory to that group.

chgrp -Ra groupname
/path/to/your/web/directory

6. Enable write permissions

chmod -R g+rw

/path/to/your/web/directory

How to give ftp users access to directories outside their home folder in Linux

Say you have 2 users, with 2 different websites:
User sonu:
  • Home folder:  /home/sonu
  • Document root, virtual-host: /var/www/sonu.com
User sujeet:
  • Home folder: /home/sujeet
  • Document root, virtualhost: /var/www/sujeet.com
And you are using vsftpd, with the setting chroot_local_user=YES so that users are limited to their own home folder.

You could create a link ( ln -s ) between /home/sujeet/sujeet.com and /var/www/sujeet.com so sujeet could manage his website from his home directory. that would work, but not via ftp, since it does not follow links outside sujeet’s home folder.

Steps:-

Instead of using the traditional link, you can in Linux mount two folders like this:
Make sure the directories /home/sujeet/sujeet.com and /var/www/sujeet.com exists (create them with mkdir)
Then mount the two folders with mount –bind  /home/sujeet/sujeet.com /var/www/sujeet.com
Now Alex should be able to update his website files in his home folder, via ftp, and at the same time, Apache can serve his website from the default /var/www directory (ubuntu default).

Note:-

This is a simpler workaround, a solution, but not to the specific problem of giving ftp users access.
Instead of linking or mounting directories between Apaches www folder and users home folder, you could just point the document root of the Apache virtual-hosts to /home/sujeet/sujeet.com or /home/sonu/sonu.com instead.

 

 

No comments:

ORA-01552: cannot use system rollback segment for non-system tablespace 'TEMP'

 ORA-01552: cannot use system rollback segment for non-system tablespace "string" Cause: Used the system rollback segment for non...