0

I am working on configuring an SFTP server on Ubuntu Server 18.04. I want to create SFTP accounts that point directly to their working directory without listing others. For example if the real working directory on the server is /sftpdir1/sftpdir2/user1, the user should see it as / and not /user1 like when using chrootdirectory: when I login via FileZilla I should find as shown in the image below 1 where I can upload and download files.

Update: why not setting chrootdirectory in /etc/ssh/sshd_config

If I have more then on user assigned to the same group, so having the same chrootdirectory, any user among will see others' working directory. Or by logging in I don't want the user to see others' dir nor the tree of his/her own working directory: just find / like shown in the image.

8
  • what is your FTP server?
    – binarysta
    Jun 4, 2020 at 12:16
  • 4
    this should be covered by 1) chroot section of man sshd and 2) inside a match user user1 section in /etc/ssh/sshd_config
    – Archemar
    Jun 4, 2020 at 12:23
  • @binarysta am using the internal-sftp Jun 4, 2020 at 13:48
  • @Archemar the chrootdirectory must be root-owned, or I want something just like the chrootdirectory but where the user (other then root) can modify it (upload and download files mainly) Jun 4, 2020 at 13:56
  • be sure to check, chroot dir is root owned, but user can use it through ssh/sftp
    – Archemar
    Jun 4, 2020 at 14:06

1 Answer 1

1

You have to accept that your users will not be able to write to the / they see. Thus you cannot really make their home directory their chroot directory. If you do not mean home directory by "working directory" then you don't have to care. Just create directories

/sftproot
   |__ user-1
   |     |___ rw-dir
   |__ user-2
   |     |___ rw-dir

and set ChrootDirectory /sftproot/%u. The user-x directories are writable only by root. No user can see the chroot directory of any other user.

using home directories

If you want the users to see their home directories then create the same directory structure, I would suggest different names, though

/sftproot
   |__ user-1
   |     |___ user-1
   |__ user-2
   |     |___ user-2

and make bind mounts like

mount --bind   /home/user-1   /sftproot/user-1/user-1

This can be done via fstab entries, too.

1
  • I've just mentioned chroot simplify explaining my prob although I don't think it is solved using chrootdirectory.. . I know chrooted directory won't appear for users, but every thing created under it will and I don't want that to happen. I want every user to point directly to his working as if it is the root Jun 4, 2020 at 20:06

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