How to add an ssh user who only has permissions to access specific folder?
useradd -d /var/www/xyz.com.tr/musteri -s /bin/bash -g sshd musteri
I created a user called musteri
. I set its home folder and group.
So, I want to integrate musteri
users into "/var/www/xyz.com.tr/musteri". I don't want it to access another folder.
Best Answer
It sounds like you want your müşteriler to have file transfer access to a folder without actually giving them shells. This is a good thing because as binfalse pointed out, giving people shells with limited access is tricky because shells need to access all kinds of things scattered on the system just to run.
In order to give SFTP access to a specific folder, you can do something like this.
/etc/ssh/sshd_config
) with these linesThis would activate the sftp subsystem inside of SSH and force members of that system group to use only that system when logging in. It would also chroot them to their home directories. You could change that to be a sub-folder of their home-directores as well with something like
ChrootDirectory %h/musteri_sftp
so that they couldn't se the rest of their system files but would login directly to a special subfolder of their home folder.Kolay gelsin.