How to Create SFTP Server Using Cygwin

How to Create SFTP Server Using Cygwin

If you want to know how to create an SFTP server using Cygwin, you just have to read on. This data storage solution offers one of the best and easiest ways of storing and accessing data from anywhere in the world. It is a secure solution that caters to businesses with any type of network architecture – be they big or small.

What is SFTP?

SFTP stands for Secure File Transfer Protocol. It is a protocol for transferring files over a network by providing authentication and encryption for file transfers. It is usually used with a secure shell (SSH) to provide secure remote access to the SFTP server. The “handshakes” between clients trying to connect and the server look like this:

The SSH handshakes

Meanwhile, SFTP servers are used to store and transfer large amounts of data, as well as to synchronize files across multiple locations.

What is an SFTP server?

An encrypted SFTP client and server session

Looking into SFTP servers in more detail, we find that they have features like:

  • Because they allow access to the remote server using an SSH connection, they provide greater security than FTP servers.
  • An SFTP server offers several advantages over other types of servers because it comes with security features like data encryption and user authentication.
  • They are easy to set up and maintain, are compatible with other operating systems, and don’t require dedicated hardware.
  • A notable feature of SFTP servers is their ability to transfer large amounts of data quickly and synchronize it across multiple locations.

An everyday use for SFTP servers is whereby developers transfer code from their local machines to these types of web-based servers. Other users can use them for file sharing between different computers in an office.

What is Cygwin?

Cygwin is a Linux-like environment for Windows. It provides the operating system with features that are available on Linux but not on Windows. Cygwin uses DLLs to serve as a Linux emulator while its toolsets provide the Linux environment.

Cygwin Linux on Windows

As an example, users can install a program that requires compiling from source code on their Windows computer with the help of Cygwin. They can also run scripts written in Bash or other Linux scripting languages.

Developers can also use it to migrate applications from Linux to Windows operating systems.

Cygwin is an open-source software package that can also be used to create an SFTP server.

Learn How to Create an SFTP Server Using Cygwin

Ok; let’s jump straight into it and find out how to create SFTP servers using Cygwin. Follow these steps:

1. Install Cygwin

You can download the setup and install the most recent version of Cygwin from their website. Remember, when you install the packages for the first time, the setup program does not install all the packages. Only the minimal base packages – about 100 MBs – from the Cygwin distribution are installed by default.

The setup program tracks the versions of all installed components and provides the mechanism for installing or updating necessary components from the home site.

Once installed, you need to include the Cygwin Binary directory (bin) in the PATH environment variable.

If, for example, Cygwin is installed in the directory “c:\cygwin“, go to:

Control Panel – System and Security – System – Advanced System Settings

Click on the “Advanced” tab then go to Environment Variables – System Variables – Select variable named “PATH” and “Edit.”

Add “c:\cygwin\bin;” in front of the existing PATH entry.

In Windows 10 it would look like this:

Cygwin Path in Windows 10

2. Launch Cygwin

Run C:\cygwin\cygwin.bat to start the Cygwin command shell.

Next, enter the command below:

set CYGWIN=binmode ntsec

3. Complete the Setup

While in the Cygwin terminal, run the following commands:

mkpasswd –l > /etc/passwd

mkgroup –l > /etc/group

Set proper permissions on passwd and group files by entering the following commands:

export CYGWIN=’ntsec tty’

chmod +rw /etc/group

chmod +rw /etc/passwd

chmod 0755 /var 

4. Add a New User as SFTP on an Existing Cygwin Installation

The first thing you need to do before creating or adding a user on Cygwin is to make sure that they already exist on Windows. Once the account has been created, log in to the Windows server with Admin privileges and open the Cygwin terminal.

Once done, you can go ahead and create as many users as you want to install the Management Agent. For a local user named John Doe, you would use:

/bin/mkpasswd -l –u johndoe >> /etc/passwd

If he were a domain user, you would run:

mkdir -p /home/johndoe

chown johndoe /home/johndoe

Next, run the following command:

mkpasswd –l > /etc/temp

This command will import the local users into a database and organize them for efficient use in the temp file.

You can open the /etc/temp file and copy the line which contains the new user configuration and append it at the end of /etc/passwd. You are now done with creating your user password and group file.

The Home directory of the new user is also defined in the line copied from the /etc/temp file. This directory can be modified manually after it has been copied into the /etc/passwd file. Also, key-based authentication can be set up for any user – just like in Linux systems.

5. Setup OpenSSH-Serve as a Service

Run the following command to initiate the ssh server configuration:


The process will ask some configuration-related questions like:

  • Should privilege separation be used? Select Yes.
  • New local account “sshd”? Select Yes.
  • Do you want to install sshd as a service? Select Yes if it has not already been installed as a service, otherwise select No.
  • Enter the value of CYGWIN for the daemon: [] ntsecbinmode nodosfilewarning
  • Do you want to use a different name? The answer depends on your choice.
  • Create a new privileged user account “cyg_server”? Select Yes.

At the end of the configuration, you will be asked to enter and confirm a password.

Note: as a reference, you can use this guide to help with the decision-making as you set up your ssh server.

6. Configure your sshd

The configuration is similar to Linux (/etc/sshd_config):

vim /etc/sshd_config

7. Test Starting and Stopping the SSH Server

The commands to start and stop the SSH server, respectively, are:

net start sshd


net stop sshd

Make sure that port 22 is open – and you don’t need to open additional ports.

You can go to your Services management console and check that it is up and running.

Cygwin sshd service

Testing your new Cygwin SFTP server

Once you have set up your SFTP server, it is time to test and see if you can access it.

To test the connection to your local SFTP server, go to the Cygwin terminal and type:

sftp.exe ftpuser@localhost

When asked, type in your password.

From a Windows device, you can use a client application like FileZilla. After setting it up, simply provide the host address, username, and password to connect to your SFTP server.

Other Applications You Can Use to Create SFTP Servers

Apart from Cygwin, you can use other solutions to create your SFTP server. Let’s have a look at two such alternative solutions available:

1. SolarWinds SFTP

SolarWinds SFTP server

SolarWinds SFTP is a free SFTP file transfer solution. It is one of the most popular solutions out there that you can use.

Key Features:

  • It offers an easy-to-use GUI that makes it a breeze to manage your server and files.
  • It allows for concurrent transfers from multiple devices, as well as the ability to authorize ranges of IP addresses.
  • The tool can be configured to run as a Windows service, making it a part of the operating system.
  • Administrators can use SolarWinds SFTP for tasks like securely pushing OS images, firmware, and configuration updates, as well as backup configuration files.
  • Users can transfer files of up to 4 GB in size.

Download SolarWinds SFTP for FREE.


Files com logo is another popular cloud-based SFTP solution. It also offers desktop, mobile, and on-premise apps that come together for a high-performance file transfer solution.

Key Features:

  • The solution has a proven track of security that comes with fine-grained permission controls.
  • It is an efficient solution where users find it easy and quick to upload and download files – even when the files are stored in multiple remote endpoints.
  • Being a cloud solution it integrates easily into architectures and comes with out-of-the-box compatibility with solutions like AWS, Azure, Google Cloud, SharePoint, OneDrive, Google Drive, Box, Dropbox, Zapier, and many more productivity tools.
  • com comes with support for huge files (up to 5 TB) and a substantial network capacity of 100 GB.
  • Security is at the forefront of this solution and includes encryption at rest and in transit, two-factor authentication, as well as configurable password and session policies.

Try for FREE.

Create your SFTP Server Now

Whether you use Cygwin or the alternative solutions (SolarWinds SFTP and is up to you. What is important is that you have a secure and easy-to-use SFTP server to store and access your files. A centralized file storage server makes it easy for collaboration and version control of your documents. It can also serve as a backup (and restore) solution when files go missing, deleted, or corrupted.

We hope you find this post helpful. If so, let us know – leave us a comment.

Leave a Reply