-1

Let's say I have a user 'user1'. This user has a special directory which can be accessed by another user ('user2'): /home/user1/directory

How can I allow ssh/sftp access for user2 only to this directory? so when user2 connects to the server via SSH/SFTP the /home/user1/directory is opened and only this directory could be accessed. user2 must have all kind of permissions within this folder only.

I was thinking about granting 777 permissions to this folder and creating a bash script to redirect to the folder but I'm not sure if this is a correct way.

Please advise.

1 Answer 1

0

I figured out the issue myself by the means of ChrootDirectory.

Here is sshd_condig:

Match user user2
        ChrootDirectory /home/user2/lock
        ForceCommand internal-sftp
        AllowTcpForwarding no
        GatewayPorts no

And I created a symlink that links /home/user2/lock with /home/user1/directory

The other solution was to change the owner of the /home/user1/directory to root and specify this directory as chroot'ed directory but that's not quite convenient in my case. Hope this will help if somebody meet the issue in the future.

You must log in to answer this question.

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