Installing SFTP - SSH Server On Windows Using OpenSSH - WinSCP
Installing SFTP - SSH Server On Windows Using OpenSSH - WinSCP
Microsoft maintains a port of OpenSSH for Windows. You can use the package to set
up an SFTP/SSH server on Windows.
Further reading
On Windows 11:
Go to Settings > Apps > Optional features and click on View features.
Locate “OpenSSH server” feature, select it, click Next, and then click
Install.
On Windows 10 (version 1803 and newer):
Go to Settings > Apps > Apps & features > Optional features and click on
Add a feature.
Locate “OpenSSH server” feature, expand it, and select Install.
Follow a generic guide for Setting up SSH public key authentication in *nix
OpenSSH server, with the following difference:
Create the .ssh folder (for the authorized_keys file) in your Windows account
profile folder (typically in C:\Users\username\.ssh).2
For permissions to the .ssh folder and the authorized_keys file, what matters
are Windows ACL permissions, not simple *nix permissions. Set the ACL so
that the respective Windows account is the owner of the folder and the file and
is the only account that has a write access to them. The account that runs
OpenSSH SSH Server service (typically SYSTEM or sshd) needs to have read
access to the file.
Though, with the default Win32-OpenSSH configuration there is an exception
set in sshd_config for accounts in Administrators group. For these, the server
uses a different location for the authorized keys file:
%ALLUSERSPROFILE%\ssh\administrators_authorized_keys (i.e. typically
C:\ProgramData\ssh\administrators_authorized_keys).
Before the first connection, find out the fingerprint of the server’s host key by
using ssh-keygen.exe for each file.
for %f in (%ProgramData%\ssh\ssh_host_*_key) do
@%WINDIR%\System32\OpenSSH\ssh-keygen.exe -l -f "%f"
C:\Windows\System32\OpenSSH>for %f in
(%ProgramData%\ssh\ssh_host_*_key) do
@%WINDIR%\System32\OpenSSH\ssh-keygen.exe -l -f "%f"
1024 SHA256:K1kYcE7GHAqHLNPBaGVLOYBQif04VLOQN9kDbiLW/eE
martin@example (DSA)
256 SHA256:7pFXY/Ad3itb6+fLlNwU3zc6X6o/ZmV3/mfyRnE46xg
martin@example (ECDSA)
256 SHA256:KFi18tCRGsQmxMPioKvg0flaFI9aI/ebXfIDIOgIVGU martin@example
(ED25519)
2048 SHA256:z6YYzqGiAb1FN55jOf/f4fqR1IJvpXlKxaZXRtP2mX8 martin@example
(RSA)
If you cannot authenticate to the server and use Windows 10 Developer mode, make
sure that your OpenSSH server does not conflict with an internal SSH server used by
the Developer mode. You may need to turn off the SSH Server Broker and SSH
Server Proxy Windows services. Or run your OpenSSH server on a different port
than 22.