Find the answer to your Linux question:
Results 1 to 2 of 2
I am trying to setup 2 individual FTP users. They should both have access to the same directory. They both need to be able to read/write into the directory. But, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2011
    Posts
    1

    Shared FTP directory - separate user permissions


    I am trying to setup 2 individual FTP users. They should both have access to the same directory. They both need to be able to read/write into the directory. But, I want them not to be able to write to each other's files (e.g. delete, remove, rename, etc.).

    So let's say the shared directory is: /home/ftp/shared/

    UserA needs read/write access to /home/ftp/shared/. UserA should only have write access to his own files.
    UserB also needs read/write access to /home/ftp/shared/. UserB should only have write access to his own files.

    It would be a unix box of sorts, but that is the only restriction. I could use whatever software. I am currently thinking pure-ftpd or vsftp but I am open to all ideas.

    Any ideas how I can accomplish this?

    Thanks.

  2. #2
    Linux Newbie Nagarjuna's Avatar
    Join Date
    Feb 2011
    Posts
    122
    Hey, jon20usa. Welcome to the forums.

    This shouldn't be too difficult for you to setup. I just created a very similar setup in RedHat. We can do this all from a terminal, so pop open your favorite shell and let's begin.

    First we want to create a group that these two users can be a part of so they can both access the FTP share. We'll call it 'ftpusers' in this example, but you may call it what you wish:

    Code:
    groupadd ftpusers
    Now, we create our users. They are called 'user1' and 'user2' in this example:

    Code:
    useradd -m -G ftpusers -d /home/ftp -s /bin/bash user1 && passwd user1
    useradd -m -G ftpusers -d /home/ftp -s /bin/bash user2 && passwd user2
    We will need a central directory that our users can access via FTP. I'm going to create it as '/home/ftp/shared':

    Code:
    mkdir -p /home/ftp/shared
    Once the directory is created, let's set it's ownership:

    Code:
    chown root:ftpusers /home/ftp/shared
    The directory is almost ready, we just need to set permissions now. The following command will give both the owner and the group read, write and execute permissions for this directory. Any outsiders won't be able to even access it:

    Code:
    chmod 770 /home/ftp/shared
    Now, to keep user1 from writing to user2's files and vice-versa is actually quite easy. Just make sure any files that you place in there have the right ownership and permissions. By default (in RedHat at least) newly created files by a user has the permissions of 654 (rw-rw-r--) with the user and group being the users username. So, depending on your distribution, you may not need to configure any umasks or primary user groups.

    Once you have your FTP server installed (I use vsftpd and love it), you can go ahead and try to log into it using the new users. They should be dropped into their home directory '/home/ftp' and access the 'shared' directory.

    There are many other ways of configuring this, and the above is really to help you get an idea on how it could work. If you need help, I'll do what I can to assist.

    Have fun.
    Last edited by Nagarjuna; 03-31-2011 at 01:45 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •