Installing, testing and uninstalling an OpenSSH-based SFTP server in Windows

Step by Step guide 

Installing and setting up an SFTP server (SSH FTP)

First you need to download and install OpenSSH from GitHub:
https://github.com/PowerShell/...
Download the archive: OpenSSH-Win64.zip

1) Extract the contents of the archive to a target directory, for example: "C:\Windows"

Installing, testing and uninstalling an OpenSSH-based SFTP server in Windows

2) Open system properties (WIN+R, command "sysdm.cpl") -> Advanced -> Environment variables
The window that appears has two sections: the top one contains user environment variables, the bottom one contains system variables.
In the system variables select "Path" variable, click on "Change...".

Installing, testing and uninstalling an OpenSSH-based SFTP server in Windows

3) In the window that opens, click on "New" and enter the OpenSSH directory path from step 1, in this example: "C:\Windows\OpenSSH-Win64"

Installing, testing and uninstalling an OpenSSH-based SFTP server in Windows

4) Launch "PowerShell" as Administrator:
Start, type "PowerShell"→ Right click on "PowerShell" → Run as Administrator

Installing, testing and uninstalling an OpenSSH-based SFTP server in Windows

5) Navigate to the OpenSSH directory, in this example: "C:\Windows\OpenSSH-Win64"

cd C:\Windows\OpenSSH-Win64

Install the OpenSSH server:
(a green "sshd and ssh-agent services successfully installed" message should appear);

.\Install-sshd.ps1

Enable autorun for SSHD service:

Set-Service -Name sshd -StartupType ‘Automatic’

Open TCP port 22 in the Windows firewall for incoming traffic to the SSH server:

New-NetFirewallRule -Protocol TCP -LocalPort 22 -Direction Inbound -Action Allow -DisplayName SSH

Set up the file owner and access rights: (Answer each question with a "Y")

.\FixHostFilePermissions.ps1
Installing, testing and uninstalling an OpenSSH-based SFTP server in Windows


6) Open service list (WIN+R, command "services.msc") -> Double click on "OpenSSH SSH Server" → Set startup type: "Automatic", click on "Run" → OK

Installing, testing and uninstalling an OpenSSH-based SFTP server in Windows

Checking SFTP connection using WinSCP

Download and run the free WinSCP client.
In the connection settings window, select the SFTP file transfer protocol, specify the server name and the details of the Windows account under which you are connecting

Installing, testing and uninstalling an OpenSSH-based SFTP server in Windows

If everything is set up correctly, the client should connect to the SFTP server and display a list of files in the user's home directory (the default directory with the user's profile).
Using the familiar file manager interface, files can be securely copied between the server and the client. File transfer will be performed via secure SFTP protocol.

Installing, testing and uninstalling an OpenSSH-based SFTP server in Windows

Uninstalling the Win32 OpenSSH service

To correctly remove the Win32 OpenSSH service from the system:

1) Launch "PowerShell" as Administrator:
Start, type "PowerShell"→ Right click on "PowerShell" → Run as Administrator

Installing, testing and uninstalling an OpenSSH-based SFTP server in Windows

2) Navigate to the OpenSSH directory, in this example: "C:\Windows\OpenSSH-Win64"

cd C:\Windows\OpenSSH-Win64

3) Stop the SSHD service:

Stop-Service sshd

4) Uninstall the OpenSSD service:

.\uninstall-sshd.ps1
Installing, testing and uninstalling an OpenSSH-based SFTP server in Windows