Win32-OpenSSH icon indicating copy to clipboard operation
Win32-OpenSSH copied to clipboard

Unable to restrict specific folder access for SFTP user in windows

Open jeraldraj opened this issue 3 years ago • 1 comments

I have configured SFTP in my Azure VM windows 2019 datacenter. I am able to connect to the server through Winscp in a different port. Now the SFTP user which I have created need to read/write only on a specific folder in C drive. I have tried steps from many blogs regarding restricting the folder access and made changes in the ssh_config file inside "programdata-->ssh-->ssh_config". After making changes in config file, when I try to start the openssh service in services.msc, the service is not starting.

Tried steps adding the below lines and dint work

Match User sftpuser1 ChrootDirectory C:\SFTP ForceCommand internal-sftp X11Forwarding no AllowTcpForwarding no

Also tried these below steps

Make a Windows group with all your SFTP users in it Make sure, this group has access to your target directorie(s) Add subsystem sftp internal-sftp to your sshd_config (or change it) Restrict the new group to a directory through ChrootDirectory in sshd_config Like this, for Example:

Match Group sftpusers ChrootDirectory C:\SFTP AllowTCPForwarding no X11Forwarding no ForceCommand internal-sftp

Nothing works!! Please do help on this

jeraldraj avatar Nov 14 '21 13:11 jeraldraj

I had the same problems, see my comment below maybe it helps: https://github.com/PowerShell/Win32-OpenSSH/issues/1941#issuecomment-1160288014

isandulache avatar Jun 20 '22 10:06 isandulache