First off, I am new to this things so my technical vocabulary may not be on par with everyone.

I have created a Windows 2016 server and installed OpenSSH SFTP server successfully. Unfortunately when I login to my SFTP user, I am able to access all the folders in C drive. I Googled and understand that this is because there is no restriction set on this user.

I have googled for several hours and came across many articles but I am getting confused by it. It seems like OpenSSH do not have an easy way to control the folder restriction to specify user and there are a few ways to do it - setting the user group policy in Windows server directly (can't seem to find an article on this), download Cygwin, use other SFTP server software, workaround with OpenSSH server config file. To be frank, I am at a loss here on which to use or follow.

My end result is to allow 1 user to have 1 access to a folder under FTP_Folder (root folder). For example, User1 can only access to Site1 folder, and User2 can only access to Site2 folder. Both Site1 and Site2 folders are stored in a root folder called FTP_Folder.

What is the best approach?

1 Answer 1


You are most likely searching for the chroot equivalent ChrootDirectory in your %programdata%\ssh\sshd_config file.

This directive is only supported with sftp sessions, which sounds to me is what you are searchivn for. A remote session (SSH) into the server (cmd.exe oder powershell.exe) would not honor this.

To setup a sftp-only chroot server, set ForceCommand to internal-sftp. You may also set up scp with chroot, by implementing a custom shell that would only allow scp and sftp.

To make this simple:

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

Like this, for Example:

Match Group myfriendlyusergroup
    ChrootDirectory /myfriendlyusergroupshomedirectory
    AllowTCPForwarding no
    X11Forwarding no
    ForceCommand internal-sftp
  • 1
    Thanks. I managed to did it prior to your post and the steps are the same and I am only looking to make it work with SFTP. It is working as what I wanted, will mark this as the solution and hopefully it helps others! Jun 23, 2020 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.