Running Windows 8.1, I ran into server refused our key problem.
Follow the instructions: https://winscp.net/eng/docs/guide_windows_openssh_server It was easy to establish a connection using the username and password Windows login. However, with username authentication combined with a private key server refused our key response was server refused our key .
Work with the public key C:\ProgramData\ssh\administrators_authorized_keys to permissions for the file: C:\ProgramData\ssh\administrators_authorized_keys
This is a useful page: https://github.com/PowerShell/Win32-OpenSSH/wiki/Troubility-Steps
Stop the two OpenSSH services, then open the command prompt with admin permissions . Then run: C:\OpenSSH-Win32>c:\OpenSSH-Win32\sshd.exe -ddd
Note: specify the full path to the exe file, otherwise sshd complains. This creates a one-time connection receiver. -ddd - verbose level 3.
After establishing a connection, a scan of the logs revealed:
debug1: trying public key file __PROGRAMDATA__/ssh/administrators_authorized_keys debug3: Failed to open file:C:/ProgramData/ssh/administrators_authorized_keys error:2 debug1: Could not open authorized keys '__PROGRAMDATA__/ssh/administrators_authorized_keys': No such file or directory
I had to create a file: C:\ProgramData\ssh\administrators_authorized_keys and copy the public key text into it, for example: ssh-rsa AAAA................MmpfXUCj rsa-key-20190505 And then save the file. I saved the file as UTF-8 with BOM . Not tested ANSI .
Then again, running a one-time command line, the logs showed:
debug1: trying public key file __PROGRAMDATA__/ssh/administrators_authorized_keys debug3: Bad permissions. Try removing permissions for user: S-1-5-11 on file C:/ProgramData/ssh/administrators_authorized_keys. Authentication refused.
S-1-5-11 is the name given to System .
To fix incorrect Bad permissions , right-click the administrators_authorized_keys file, go to the Security Tab , click the Advanced button and delete the inherited permissions. Then delete all Group or user names: except the Windows YourMachineName\username , for example: YourMachineName\username . Permissions for this, the username must be " Read Allow ," Write Deny everything else has not been verified. YourMachineName\username must also be the owner of the file
This solved the problem.
Other useful links:
Download the OpenSSH-Win32.zip file at : https://github.com/PowerShell/Win32-OpenSSH/releases.
Example of using C # WinSCPnet.dll to connect to an OpenSSH server: https://winscp.net/eng/docs/library#csharp
Here is a snippet of code to connect using WinSCPnet.dll :
static void WinSCPTest() { SessionOptions ops = new SessionOptions { Protocol = Protocol.Sftp, PortNumber = 22, HostName = "192.168.1.188", UserName = "user123", //Password = "Password1", SshHostKeyFingerprint = @"ssh-rsa 2048 qu0f........................ddowUUXA=" }; ops.SshPrivateKeyPath = @"C:\temp\rsa-key-20190505.ppk"; using (Session session = new Session()) { session.Open(ops); MessageBox.Show("success"); } }
Replace SshHostKeyFingerprint and SshPrivateKeyPath with your own values.
Edit: added screenshot of access rights to administrator_authorized_keys files: 
When OpenSSH SSH Server runs as a Service, only System should have permission. However, if you run sshd.exe from the command line, the current user should be the only one in the list (reading is allowed, writing is prohibited).