The FTP protocol is one of the oldest protocols (it is more than 40 years old), but it is still widely used where a simple file transfer protocol is required. It is possible to install an FTP server on any version of Microsoft operation system. Last deep modernization of the ftp service was made in Windows 7 / Server 2008 R2 (actually the service code has almost been written from scratch). The security of the service has significantly improved and a number of new features have appeared. In particular, FTP server on Windows allows you to configure FTP user isolation. It allows to restrict access of many users to their own folders on a single FTP server.
Due to the isolation, users can work only with their folders and can’t go up in the FTP directory tree (the user’s top ftp level directory is displayed as the root of the FTP server). Thus, the access to the data of other users on the FTP server can be prevented. FTP user isolation is widely used by ISP/hosting providers when it is necessary to provide individual access to a single file storage for different users.
Like in previous Windows versions, the FTP service in Windows Server 2016 / 2012 R2 (do not confuse it with sFTP and TFTP) is based and deeply integrated into the IIS service and has a single administrative management interface.
In this article we’ll show how to install an IIS-based FTP server on Windows Server 2016/2012 R2 and configure the FTP user isolation (this manual also applies to Windows 10 and 8.1).
How to Install the FTP Server Role on Windows Server 2016/ 2012 R2?
You can install the FTP service using the Server Manager console by checking the option FTP Service and FTP Extensibility in the section Web Server (IIS) -> FTP Server.
Also you can install the FTP server role with a single PowerShell command:
Install-WindowsFeature Web-FTP-Server
To install the FTP server management console, run the following command:
Install-WindowsFeature -Name "Web-Mgmt-Console"
Creating an FTP Site, Managing FTP User Permissions
Start the Server Manager and open the IIS management console (Internet Information Service Manager).
Create a new FTP site (Sites -> Add FTP Site).
The name of the FTP site: MyTestSite
The root directory of the FTP site: C:\inetpub\ftproot
To protect the FTP data transmitted over the network, it is possible to configure FTPS/SSL for FTP (in this case, all the data and passwords/accounts sent by ftp users during session will be encrypted), but in our demonstration this is not necessary. All other settings are left default.
Import-Module WebAdministration
# Set the FTP site name
$FTPSiteName = 'CORP_FTP'
#FTP folder
$FTPRoot = 'D:\www\FTPRoot'
#FTP port
$FTPPort = 21
New-WebFtpSite -Name $FTPSiteName -PhysicalPath $FTPRoot -Port $FTPPort
Select a new FTP site and disable the Anonymous Authentication in the FTP Authentication section. Basic Authentication must be enabled.
The FTP service on Windows Server 2016/2012 R2 can use two account types: domain or local. Depending on the account type, there are some differences in the structure of FTP directories and user isolation settings. To make it easier to describe, we will use local Windows accounts.
Create some FTP users, suppose, these are ftp_user1, ftp_user2 and ftp_user3. Also create a group ftp_users which includes these users. You can create local users in the Local Users and Groups section of the Computer Management console.
You can also create local users and groups from the command prompt (or using PowerShell). Create a local group:
net localgroup ftp_users /add
Create a new local user:
net user ftp_user1 /add *
Add user to group:
net localgroup ftp_users ftp_user1 /add
Create the two other users in the same way.
Assign the Read&Write permissions on the directory C:\inetpub\ftproot for the ftp_users group.
Create a directory with the name LocalUser (the name must be the same, it’s important!!!) in the folder C:\inetpub\ftproot. Then make three directories under with the names ftp_user1, ftp_user2, ftp_user3 in the folder C:\inetpub\ftproot\LocalUser.
Account Type | Syntax of Home Directory Naming |
Anonymous users | %FtpRoot%\LocalUser\Public |
Local Windows account | %FtpRoot%\LocalUser\%UserName% |
Domain Windows account | %FtpRoot%\%UserDomain%\%UserName% |
Special IIS Manager or ASP.NET accounts | %FtpRoot%\LocalUser\%UserName% |
Return to the IIS console and create a new rule (Add AllowRules) in FTP Authorization Rules section of the site. Specify that ftp_users group must have the read and write permisions.
How to Configure FTP User Isolation on Windows Server 2016/2012 R2?
Let’s move to configuring FTP user isolation. The isolation of FTP users is configured on the FTP site level, not the entire server. FTP user isolation allows you to organize your ftp-home folder for each user.
Open FTP User Isolation in the settings of the FTP site.
This section contains several settings. The first two of them don’t suggest user isolation:
- FTP root directory (an FTP session of a user starts in the root directory of the FTP site);
- User name directory (the user starts with physical/virtual directory with the username. If the directory is missing, a session starts in the root FTP directory of the site).
The next three options are different modes of user isolation:
- User name directory (disable global virtual directories) suggests that the ftp session of a user is isolated in a physical/virtual directory that has the same name as the ftp user. Users see only their own directory (it is their root ftp-directory) and cannot go beyond it (to the upper directory of the FTP tree). Any global virtual directories are ignored;
- User name physical directory (enable global virtual directories) suggests that the ftp session of a user is isolated in a physical directory that has the same name as the name of the ftp user account. A user cannot go above its directory. However, all created global virtual directories are available to the user;
- FTP home directory configured in Active Directory – an FTP user is isolated within his home directory specified in the settings of his Active Directory account (FTPRoot and FTPDir properties).
Select the required isolation mode (I use the second option to isolate ftp users).
Configuring Windows Firewall Rules to Access the FTP Server
When you install the FTP server role, all necessary rules that are needed for users to access FTP are automatically activated in the Windows Firewall settings.
For FTP to work correctly in passive FTP mode, users need to connect to the RPC port range (1025-65535). In order not to open all these ports on an external firewall, you can limit the range of dynamic TCP ports used for FTP data transmission.
- Open the FTP Firewall Support section in FTP site settings and in the Data Channel Port Range field specify the port range that you want to use for FTP connections. For example – 50000-50100;
- Save the changes and restart IIS (
iisreset
); - Open the Windows Control Panel and go to the Control Panel\System and Security\Windows Firewall\Allowed apps;
- Make sure that the list of applications that are allowed access through the firewall contains permissions for the FTP Server role.
Then check that the following rules are enabled in the settings of Windows Firewall with Advanced Security:
- FTP Server (FTP Traffic-In) – TCP protocol, port 21;
- FTP Server Passive (FTP Passive Traffic-In) – local port address 1024-65535 (50000-50100 in our case);
- FTP Server Secure (FTP SSL Traffic-In) –port 990 (when using FTP with SSL);
- FTP Server (FTP Traffic-Out) – port 20;
- FTP Server Secure (FTP SSL Traffic-Out) –port 989 (when using FTP with SSL).
Accordingly, these ports need to be opened on your router (gateway, firewall) so that external FTP users can connect to your site.
Testing an FTP Server Connection from Windows
You can check the availability of ports on an FTP server using the Test-NetConnection cmdlet:
Test-NetConnection -ComputerName yourftpservername -Port 21
Or using the ftp command:
ftp yourftpservername
Try to connect to your FTP site with any FTP client or directly from File Explorer (specify ftp://yourservername/ in the address bar).
Enter the user name and password.
And now you have access to the home directory with the user’s files (which is the root of the FTP site for the user). As we can see, the user session is isolated and the user sees only his files on the ftp server.
You can use FTP logs to view information about user access to the FTP server. The log files are stored by default in the c:\inetpub\logs\logfiles folder in the u_exYYMMDD.log files.
To view the active user connections to your FTP server, you can use the values of the IIS performance counters through PowerShell or the “Current FTP Sessions” section in the IIS console. In this console, you can view the names and the IP address of the FTP user’s and disconnect the ftp-session if necessary.
So, we have looked at how to configure an FTP site with the user isolation based on Windows Server 2016 / 2012 R2. In the isolation mode the users are authenticated on FTP using their local or domain credentials to access their root directory corresponding to the username.
7 comments
Hi,
I am trying to build the same but I am using a secure FTP setup or FTP over SSL so I have to use a secure FTP client to access the site such as CoreFTP or filezilla and for whatever reason I am able to see other users folders even though I am not able to access them.
but I am setting this for a sensitive data transfer so I can’t allow users to see other users folders, because they can be part of different customers.
any ideas?
Try at NTFS level prevent users from displaying content of root folder (List folder permission).
Which user isolation mode do you use?
Hi,
Thank you for your instructions, very helpful! However, I need to have home directory for FTP site on D: drive not C:\inetpub\ftproot. How can I change it in Windows 2012 server?
Thank you,
megan
Hi
To change the default Home directory on IIS FTP server
1) Right click on the FTP site Manage FTP Site ->Advanced Settings
2) Then change the PhysicalPath> to one you want (by default %systemdrive%\inetpub\ftproot
Hi
I’m trying to set up an FTP server that uses ActiceDirectory. My problem is that access to folders in FTP is governed by group membership. So, all members of a AD specified group have access to a specified folder. Users can be members of multiple AD groups so they can have access to multiple folders. I’m not sure how to go about this, being new to windows.
Any help is much appreciated.
Thanks
John
Hi, John
You can for each directory on the FTP server on the NTFS level permissions assign rights for certain Active Directory groups
Thank you. Poor documentation for the isolation portion left me guessing! The LocalUser / Domain directory was what I was missing.