Linux – Allow User To Access Other User’s Home Directory

chrootfedoralinuxsftp

I have a Fedora server.
I would create an SFTP user account which is allowed to access other user's home dir. Is it possible?
For example

user1 -> /home/user1
user2 -> /home/user1

user2 can access the system in SFTP.
I create the user2 with group generic-group and chrooted it:

(in my /etc/ssh/sshd_config)

AllowUsers user1 user2
Match Group generic-group
  ChrootDirectory %h
  ForceCommand internal-sftp
  AllowTcpForwarding no
  AllowAgentForwarding no
  X11Forwarding no

When I try to access in SFTP the system as user2, in the /var/log/secure:

Jan 31 11:46:24 perseo sshd[30073]: fatal: bad ownership or modes for chroot directory component "/home/user1/"

I also tried this different rule:

Match Group sftpusers
        ChrootDirectory /sftp/%u
        ForceCommand internal-sftp

and

mount --bind /sftp/user2/ /home/user1

with no success.

Best Answer

You give user1 and user2 one directory to share on the remote server ? with group write permission.

chroot is used to set up a restrictive environment (a mini root file system) then within there a /home/shared_directory could sit.

The first error is because you set the chrootdirectory to the users home directory (everything in chroot should be owned by root and not writable).

The second error you are setting the chroot to /sftp/username

Here's a similar question.

Chroot SFTP users who require access to multiple directories under same parent folder

Related Question