2

OS: Ubuntu 16.04.6

I have created one FTP server using vsftpd. I initially followed instructions from the following link.

How To Set Up vsftpd for a User's Directory on Ubuntu 16.04

But above tutorial as well as most other resources teach about making a server for a directory under home. But I wanted to make it for two of my external drives; /media/Drive-1 & /media/Drive-2

I did so by using,

sudo mount --bind /media/Drive-1/ /home/home_user/ftp_user

Now the problem is,

  • Whenever I make a directory, copy a file etc. using (say) gftp, my home_user can't change/delete it.

  • Similarly, if I make a directory or file using home_user, the ftp_user cannot change/delete it.

Now some directories are owned by 'home_user' and some are 'ftp_user'. Is there a way to grant all the directories same access, so anything I create/send through gftp or ssh or manually as the home user is accessible by both home_user and ftp_user.?

PS: Drives are EXT4 file-system.

2
  • Important info we need: are those drives are NTFS formatted?
    – Rinzwind
    Jul 16, 2019 at 8:30
  • @Rinzwind I updated my question
    – ObiWan
    Jul 17, 2019 at 5:03

1 Answer 1

3

Now some directories are owned by 'home_user' and some are 'ftp_user'. Is there a way to grant all the directories same access, so anything I create/send through gftp or ssh or manually as the home user is accessible by both home_user and ftp_user.?

Yes. There are 3 sets of permissions:

  • user
  • group
  • others

Each with 3 options: read and/or write and/or execute. When users 'home_user' and 'ftp_user' are in the same group they can do the same actions on files as if they would own them.

Easiest (and more secure then the other way around) is to add your 'home_user' to the group 'ftp_user' is set. That would be (change the 2 between {} to what it is for you):

usermod -a -G {group_ftp_user} {home_user}

If ssh and ftp use different users and groups you could also create a new group 1st

sudo groupadd {new_group}

and then add all 3 to that new group with the 1st command.

Also see

local_umask=

in

/etc/vsftpd.conf

You need to set that to 007 (it will now be set to 700).

6
  • Thanks for your answer. I added my ftp_user into my home_user group. I added a directory and a file using gftp. The output of ls -l is; drwx------ 2 ftp_user ftp_user 4096 Jul 17 13:10 tempp. I guess ftp_user has a group of its own. What should be done in this case.
    – ObiWan
    Jul 17, 2019 at 7:45
  • 1
    Like I said in the answer: add "home-user" to group "ftp_user". "ftp_user into my home_user group" No. I said add "home_user" to frp group. Please keep security in mind. You do not want an ftp user to be able to alter files the user of the system owns.
    – Rinzwind
    Jul 17, 2019 at 7:53
  • Yeah you are right, I did the reverse. Now I added 'home_user' into group of 'ftp_user' which has the same name, i.e. 'ftp_user'. But even after doing this, when I added a folder using gftp i get this; drwx------ 2 ftp_user ftp_user 4096 Jul 17 14:46 new_directory. Shouldn't I be getting, drwxrwxrwx 2 ftp_user ftp_user 4096 Jul 17 14:46 new_directory
    – ObiWan
    Jul 17, 2019 at 9:20
  • 1
    no you need drwxrwx--- (or 770 for directories) and drw-rw---- (for files; executable bit should be a manual action) But that should be an option in the ftp software you use. It is probably set to 700.
    – Rinzwind
    Jul 17, 2019 at 9:40
  • ah see "local_umask" in "/etc/vsftpd.conf".
    – Rinzwind
    Jul 17, 2019 at 9:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .