How to configure SFTP Server using OpenSSH on Windows Server 2016? Security

SFTP stands for SSH file transfer protocol or Secure File Transfer Protocol. This pacgage works over a secure connection and the advantage is the ability to leverage a secure connection to transfer files and traverse the filesystem on both local and remote system.

The following steps shows how to setup SFTP using OpenSSH on Windows 2016 Server

Step 1: Download the OpenSSH from the link https://github.com/PowerShell/Win32-OpenSSH/releases”>Make This Nofollow

Step 2: Locate the downloaded file, right-click and Extract All to C:\Program Files\OpenSSH-Win64

Step 3: Modify the Path system environment variable by running the command “/” or add the variable in System Properties -> Environment variable path

To setup the environment variable using PowerShell –

  1. Open PowerShell as Administrator
  2. Setx PATH “$env:path; C:\Program Files\OpenSSH-Win64” –m

You should see the following output-

SUCCESS: Specified value was saved

Step 4: Change to the OpenSSH directory

                cd “C:\Program Files\OpenSSH-Win64”

Step 5: Run the install script

                .\install-sshd.ps1

OR run in PowerShell as below

                PS C:\windows\system32> powershell.exe –ExecutionPolicy Bypass –File install-sshd.ps1

Step 6: Enable automatic startup and start sshd and ssh-agent

                Set-Service sshd -StartupType Automatic; Set-Service ssh-agent -StartupType Automatic; Start-Service sshd; Start-Service ssh-agent

Step 7: Allow Access in Windows Firewall

a. Open Windows Firewall and create a new inbound rule for SFTP

Windows Firewall

b. Create a new rule and select custom and select protocol and ports

protocol and ports

Create a new rule and select custom and select protocol and ports

c. Under the section Scope, let the rule apply to Any IP Address from remote and local IP addresses and click Next

d. Under Action, select Allow the connection and click Next

e. Name the Rule and select Finish

To enable port via PowerShell, please execute the follow command

                >New-NetFirewallRule -Name sshd -DisplayName ‘OpenSSH SSH Server’ -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 -Program “C:\System32\OpenSSH\sshd.exe”

Step 8: Edit the sshd_config file and make the following changes to add path and user /group

Edit the sshd_config file

sshd_config file

Step 9: Stop and restart the sshd services by executing the following command

                Net stop sshd

                Net start sshd

Stop and restart the sshd services

SFTP Is configured successfully using OpenSSH

At Velan, our server support engineers can help you setup sftp server using OpenSSH on Windows 2016 server. We troubleshoot problems like these for our clients every day. If you are interested in our service, please fill the Quick connect form to get in touch with us

Credentials

Quick Connect With Us