121

I am having issues setting up OpenSSH for Windows, using public key authentication.

I have this working on my local desktop and can ssh with a key from Unix machines or other OpenSSH for Windows machines.

I have replicated the build onto a server, I can get password authentication working fine, but when I use the keys I get the following issue:

debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug3: start over, passed a different list publickey,password,keyboard-interactive
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /cygdrive/c/sshusers/jsadmint2232/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
Connection closed by 127.0.0.1

So for the purposes of testing, I have been just trying to SSH to localhost, but even when tried remotely I get the same issue.

Even more strange, is that when I have both password and public key enabled in sshd_config, it will only attempt to use keys and then bomb out with the above message and won't even try to use password.

Here are the steps I have taken:

  1. Install OpenSSH for Windows
  2. mkgroup -l >>..\etc\group (added local groups)
  3. mkgroup -d >>..\etc\group (added domain groups)
  4. mkpasswd -L -u openssh >>..\passwd (added my local user)
  5. mkpasswd -D -u jsadmint2232 >>..\passwd (added my domain user)
  6. Edited the homedir in file passwd to point to c:\sshusers%USER% - where %USER% is the user name
  7. Enabled password authentication, disabled key authentication
  8. Created SSH keys for both jsadmint2232 / OpenSSH and ensured that the files were created in home directories
  9. Added authorized_keys files into .ssh directories for each user and added keys for incoming connecting users
  10. net stop opensshd / net start opensshd
  11. Test if password authentication works both locally and remotely
  12. Updated sshd_config, to enabled key auth - restart opensshd
  13. Test connection and get above error. Also, it doesn't even try password authentication.
  14. Updated sshd_config, to disable password authentication completely - restart opensshd
  15. Test connection and still get above error

It appears the server is killing the connection for some reason.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Cambolie
  • 1,415
  • 2
  • 12
  • 14

13 Answers13

353

Following are setup steps for OpenSSH shipped with Windows 10 v.1803 (April 2018 update. See comments to this post, it might not work with 1809).

Server setup (elevated powershell):

  1. Install OpenSSH server: Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0.

  2. Start agent and sshd services: Start-Service ssh-agent; Start-Service sshd (this will generate host keys and default configuration automatically in $env:ProgramData\ssh).

  3. [Optional] Install OpenSSHUtils powershell module: Install-Module -Force OpenSSHUtils

Client setup (non-elevated powershell):

  1. Generate user key: cd $env:USERPROFILE\.ssh; ssh-keygen.exe, follow prompts, agree to the default suggested file location. This will create 2 files: id_rsa and id_rsa.pub;

  2. [Optional] add key to authentication agent, so you don't have to enter password each time you use it: ssh-add .\id_rsa (or whatever file was generated);

Server setup continued (non-elevated powershell):

  1. Log in as a user, for which public key auth to be used
  2. cd $env:USERPROFILE; mkdir .ssh; cd .ssh; New-Item authorized_keys;
  3. Paste the contents of the id_rsa.pub file from the client to the .ssh\authorized_keys file from the previous step. Make sure it is encoded as UTF-8.
  4. Setup permissions properly (important!!!):
  5. Run start . to open explorer with the current folder ($env:USERPROFILE\.ssh);
  6. Right click authorized_keys, go to Properties -> Security -> Advanced
  7. Click "Disable inheritance";
  8. Choose "Convert inherited permissions into explicit permissions on this object" when prompted;
  9. (really, really important) Remove all permissions on file except for the SYSTEM and yourself. There must be exactly two permission entries on the file. Some guides suggest running the Repair-AuthorizedKeyPermission $env:USERPROFILE\.ssh\authorized_keys - this will try to add the sshd user to the permission list and it will break the authentication, so, don't do that, or at least do not agree on adding the sshd user). Both SYSTEM and yourself should have full control over the file.
  10. If your Windows build is 1809 or later, it is required to comment out the following lines in C:\ProgramData\ssh\sshd_config file. Then restart the sshd service.
    # Match Group administrators                                                    
    #       AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys  
    

Client:

  1. Run ssh <serverusername>@<serverhostname>. It should work at this point.

Tried that with Windows 10 as server and both itself and a Debian Linux as a client.

Cyrill
  • 165
  • 1
  • 5
n0rd
  • 11,850
  • 5
  • 35
  • 56
  • 6
    You are my hero @n0rd... Have been struggling for hours for setting the permissions right, but it seems the Repair-AuthorizedKeyPermission set the sshd user, which did break it! (I though it should be there for the OpenSSH SSH Server process to view it). thanks a lot! – gabn88 Jul 15 '18 at 19:23
  • 3
    Thank you! I have been dealing with this issue for a long time until I've read your answer! – rhcpfan Sep 04 '18 at 19:03
  • 1
    Doesn't work for me. I exactly followed the server setup instructions. So I have this authorized_keys file with only System User and myself in the permissions list as described but SSHing to the windows server does not work with SSH key. Only with password. It works fine with a linux server as target with the same authorized_keys file. – kayahr Oct 07 '18 at 12:33
  • Follow up to my last comment: I tried it on another Windows machine (1803). It works there. It does not work on Windows 10 1809. Did Microsoft screw something up? Or are more configuration changes needed for this windows version? – kayahr Oct 07 '18 at 12:44
  • 40
    Another follow up and solution for my problem: In Windows 10 1809 there is new special config entry in `C:\ProgramData\ssh\sshd_config` which defines that for admin users the keys are read from `__PROGRAMDATA__/ssh/administrators_authorized_keys`. Again this file needs special permissions. Only system user and administrators group must have access to it. – kayahr Oct 07 '18 at 13:13
  • Feel free to post that as an answer, I don't have 1809 yet, so I can't verify. – n0rd Oct 08 '18 at 23:42
  • 1
    I can confirm in 1809 that the solution @kayahr presented was what I had to do to authenticate via public key, due to the fact my user is an administrator. Thanks @kayahr! – pwbred Nov 25 '18 at 20:30
  • A side note: the `ssh_config` file was not present in my system, but I needed to instruch ssh.exe to search for a further RSA key besides the one in the `id_rsa` file. So I created the `ssh_config` file from scratch in `c:\ProgramData\ssh` with `wsl vim ssh_config` command, launched from an Administrator/elevated command prompt. I pasted the content of the default `ssh_config` present in my WSL installation, and added `IdentityFile ~/.ssh/id_rsa_2` to instruct the `ssh` client to look for the second key too. It did the trick. Windows version: 10.0.17763.348. – shub Mar 09 '19 at 03:06
  • For some powershell to avoid needing to comment out the `match group administrators` part, see https://github.com/jen20/packer-aws-windows-ssh/blob/master/files/configure-source-ssh.ps1#L99-L114 (via https://operator-error.com/2018/04/16/windows-amis-with-even/) Thanks @jen20! – Peter Mounce Jun 12 '19 at 15:48
  • 8
    This was a huge help, but permissions were still an issue. These 3 commands fixed it: `icacls C:\ProgramData\ssh\administrators_authorized_keys /remove "NT AUTHORITY\Authenticated Users"` and `icacls C:\ProgramData\ssh\administrators_authorized_keys /inheritance:r` and `get-acl C:\ProgramData\ssh\ssh_host_dsa_key | set-acl C:\ProgramData\ssh\administrators_authorized_keys` [source](https://learn.microsoft.com/en-us/windows/iot-core/connect-your-device/ssh) – bitinerant Jun 28 '19 at 15:08
  • 10
    Thank you ! To be able to use passwordless key authentication, with authorized_keys file in "user/.ssh", I needed to comment out the lines `# Match Group administrators # AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys `, and restart service "OpenSSH SSH Server". – trogne Sep 09 '19 at 17:49
  • My `sshd_config` file did not have the lines you mention but I noticed that the in the **Authentication** section the `PubkeyAuthentication yes` line was commented out. Uncommenting and restarting the services worked for me! Hope it helps – Efi Kaltirimidou Oct 05 '19 at 12:01
  • Something I missed the first time - in addition to the permissions on the authorized_keys file, the owner of the public key file must also be the user whose home folder it lives under. – Patrick Stephansen Oct 21 '19 at 16:00
  • awesome, this worked for me with Windows Server 2019 v.1809 – xCovelus Jan 15 '20 at 15:52
  • I can verify this method still works on v.2004 (insiders' version) – R. Zhu Jan 16 '20 at 01:17
  • Commenting out as in 5 solved this for me in Windows 10 Enterprise build 18383. Life saver, thanks! – Karlsson Apr 27 '20 at 17:18
  • The basic ideas here worked for me on Windows 10 Pro 2004, but changing the permissions on `id_rsa` was *not* required. The important parts of the SSH configuration that needed to be done were uncomment the `PubkeyAuthentication yes` line, and comment out the `Match Group administrators` section. (Optionally, uncomment and set `PasswordAuthentication no` if you don't want to allow password access) – Herohtar Sep 09 '20 at 06:12
  • Burned a whole day until I ran into your post. Worked also for 1809. That permission issue... why doesn't the logs say anything?? damn.. – Elior Malul Oct 02 '20 at 12:41
  • 2
    @EliorMalul, I actually figured it out from reading the logs. The issue is that by default sshd does not log much, you need to crank verbosity to 11 (`LogLevel DEBUG3` in `sshd_config`) to get something useful from it. – n0rd Oct 02 '20 at 17:47
  • Possible update in v1909, I had to have SYSTEM, **ADMINISTRATORS**, and my user in the access list. – joshhemphill Nov 27 '20 at 06:31
  • 1
    I don't know why this is not the accepted answer! I was searching for hours and your answer is the only one that worked!!! Thank you so much!!! – babaliaris Jan 03 '21 at 23:35
  • Regarding "There must be exactly two permission entries on the file" I noticed that extra permissions to the "Administrators" group don't cause problems. – ndemou Jan 26 '21 at 16:42
  • 1
    The easiest one liner to fix the issue of authorized_keys being setup wrong seems to be `icacls.exe "$($env:USERPROFILE)/.ssh/authorized_keys" /inheritance:r /grant "$($env:USERNAME):F" /grant "NT AUTHORITY\SYSTEM:F"`. This is the only thing that halts OpenSSH from working out of the box for me, no other permissions changes are required; this also seems to replicate the intended behavior of `Repair-AuthorizedKeyPermission`, but without several hundred lines of Powershell. – Diablo-D3 Feb 14 '21 at 18:38
  • @Herohtar `#PubkeyAuthentication yes` uncommenting it did not make a difference, so you can leave it commented. In Linux you need to uncomment. – Timo Jun 22 '21 at 15:53
  • @Timo If it made no difference then maybe you were editing the wrong file. sshd won't use public key authentication unless you tell it to with that setting, doesn't matter if it's Windows or Linux. – Herohtar Jun 23 '21 at 02:47
  • Worked for several months. But then I had to redo step 4, as the key auth suddenly stopped working. Permissions for Administrators and my Administrator user (my user is non-admin) somehow showed up for the authorized_keys file again.. – Adam Jul 20 '21 at 12:05
  • It still isn't working for me. My user account is an admin account, and the _only_ thing that works is actually to stop the SSH server service and run `sshd -d` from the command line. I presume this is because it's now running under my user account instead of `SYSTEM`. @n0rd: where did you find the logs that guided you through this? I modified `sshd_config` with your DEBUG3 setting, but the Event Viewer's Security logs don't seem to mention ssh. – Andrew Arnott Aug 30 '21 at 01:24
  • @AndrewArnott, if you specify `SyslogFacility LOCAL0` `sshd` will write logs to a `%PROGRAMDATA%\ssh\logs\sshd.log` file. I used that one. – n0rd Aug 30 '21 at 05:25
  • 1
    Thank you, fixing the permissions on the windows user profile copy of `.ssh/authorized_keys` finally fixed this for me after hours of trying different things. I also found I was able to get away with just giving the SYTEM user read permissions instead of full control. It may be worth calling out that the windows copy of sshd doesn't look at the WSL /home//.ssh dir for authorized_keys. (which makes sense because it's the server and you can have multiple WSLs, but can be confusing if your ssh-ing from inside there and the client is picking up id_rsa and known_hosts etc from there). – Mark Smith Jan 16 '22 at 20:07
  • 1
    One more thing to add, make sure that your authorized_keys or administrators_authorized_keys is encoded in UTF-8. I found one way is to open in notepad, do Save As... and select UTF-8 for the encoding. I struggled for days on this wondering why is this working for everyone else. – kalypzo Apr 14 '22 at 23:24
  • This still does not work for me. The only way I was able to successfully connect from the remote computer was to stop the sshd service, and run it in a powershell terminal instead. Once I did that, I was able to ssh in from the remote computer using my public key. That tells me the public key is configured correctly, but there is a problem running the service under "Local System", as another answer pointed out. However, it doesn't seem right to change the service to run under my account. Any suggestions on how to debug this further? Not seeing any useful logs about permission errors. – Joshua Flanagan Jul 29 '22 at 03:32
  • THANK YOU SO MUCH! Step 5 fixed it for me on Windows 11 22H2! <3 – lxhom Nov 05 '22 at 19:56
  • Like @kalypzo said, make sure to encode `authorized_keys` as **UTF-8**. I struggled for hours before checking with PS>`Format-Hex .\.ssh\authorized_keys` – Cyrill Mar 13 '23 at 10:44
  • @Cyrill, unless computer/username contain non-latin characters, everything else in the .pub file should fit into ASCII (and hence be covered by pretty much any encoding actually used except UTF-16/32). Was that the issue? How sensitive sshd is to the presence of BOM in the `authorized_keys` file? – n0rd Mar 14 '23 at 23:34
  • @n0rd Since i was on a fresh install of Windows I used the builtin Editor, which defaults to utf16 apparently. – Cyrill Mar 16 '23 at 06:47
31

Use this sequence of commands in PowerShell to correct permission of administrators_authorized_keys

$acl = Get-Acl C:\ProgramData\ssh\administrators_authorized_keys
$acl.SetAccessRuleProtection($true, $false)
$administratorsRule = New-Object system.security.accesscontrol.filesystemaccessrule("Administrators","FullControl","Allow")
$systemRule = New-Object system.security.accesscontrol.filesystemaccessrule("SYSTEM","FullControl","Allow")
$acl.SetAccessRule($administratorsRule)
$acl.SetAccessRule($systemRule)
$acl | Set-Acl

Only SYSTEM and Administrators group must be have permission in file without inherited.

Permission set of administrators_authorized_keys

Sergio Cabral
  • 6,490
  • 2
  • 35
  • 37
  • 3
    How surprising as it may seem, the above solution will only work on a system where the language is set to English. On a Windows 10 in French language for example, you have to replace "Administrators" with "Administrateurs" and "System" with "Système". Suprising, right? – John Smith Optional Oct 03 '21 at 23:53
  • 1
    @JohnSmithOptional Better use already existing acl to created file: `get-acl C:\ProgramData\ssh\ssh_host_dsa_key | set-acl C:\ProgramData\ssh\administrators_authorized_keys ` – SolomidHero May 22 '22 at 19:05
  • 1
    Thanks for the tip, SolomidHero. That's an interesting solution, but that supposes you have a file at hand that you know has the correct acl to begin with. That said, it is good to know you can copy acl from one file to another like that. – John Smith Optional May 23 '22 at 10:29
24

One more tip, if you are stuck, is to run sshd in debug mode. I did this:

  1. Stop the sshd service
  2. Open a PowerShell console with administrator privileges
  3. Type 'sshd -d'
  4. Type login from my client machine

It turns out the key need to be in e.g. C:\ProgramData\ssh\administrators_authorized_keys instead of C:\Users\yourUsser.ssh\authorized_keys.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
gWay
  • 1,087
  • 9
  • 7
  • 4
    Very useful answer for me. It helps not only to answer the question what is the problem but also how to solve similar problems next time. – Arty Sep 30 '20 at 18:10
8

I have solved the issue...

It is related to the account that started the service - it was using the Local System account - this was stopping it accessing the public key and authorized_keys file.

Once I stopped the service and started as the user I was trying to connect into, it worked!

So basically, you need to start with a service account and then external users connect in as that user.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Cambolie
  • 1,415
  • 2
  • 12
  • 14
  • 3
    What do you mean you "stopped the service and started as the user I was trying to connect into?" I don't suppose you mean I use my actual domain user account. Then you suggest I start with a service account, but which one? – ShieldOfSalvation Mar 15 '19 at 00:17
  • 2
    I would recommend reading @n0rd's answer below before looking into this answer at all. – Michael May 28 '20 at 19:24
  • This also fixed the problem for me - but I don't think it is the proper solution. – Joshua Flanagan Jul 29 '22 at 03:10
6

n0rd's solution is on the money but there's an added complication for users that are also in the administrator's group. If you're looking for a solution to a situation involving the following conditions:

  • You want to use public keys on a per-user basis (or you don't want to use the administrators_authorized_keys file).
  • And you don't want to use PasswordAuthentication.
  • And some of the users also belong to the admin group.

The issue I ran across is that when I tried n0rd's solution it didn't work for users under the conditions above. After some tinkering, I found a solution that works consistently for me. Follow n0rd's solution and just change the following

In the ssh_config make sure the following settings are set:

AuthorizedKeysFile  .ssh/authorized_keys 
PasswordAuthentication no
PubkeyAuthentication yes

Also, make sure to comment out the Match Group Administrators setting:

#Match Group administrators
#       AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys

Make sure to include the client's public key in the servers C:\Users\username\.ssh\authorized_keys file.

Finally, to help match the user to the account I found it helpful to be more specific with the user data on the client. Instead of using the plain username, I used the username along with the domain of the user on the server. In my case, my client's C:\Users\UserName\.ssh\config file looked like this:

Host my_short_name
  HostName my.serveraddress.net
  User serversname\username
  IdentityFile .ssh\id_rsa

In this case, my Windows 10 server would be called serversname (under device name). By specifying the user in this way I could avoid password authentication.

As an added bonus, this worked very well with a default shell of PowerShell 7. Even my default PowerShell profile worked over ssh and I got full support for posh-git and oh-my-posh. However, I found that the default method suggested for making PowerShell the default shell environment, (by editing the ssh_conf to include 'Subsystem powershell c:/progra~1/powershell/7/pwsh.exe -sshs -NoLogo') did not work for me. Instead, on the server use the command in an elevated PowerShell window:

New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "c:/progra~1/powershell/7/pwsh.exe" -PropertyType String -Force

This just creates a registry entry. You can always pop in the registry to remove it later if you want.

NatePhysics
  • 103
  • 2
  • 7
  • 2
    I don't know the exact reason why this helped, but commenting the `Match Group Administrators` setting solved my issue. As somebody told below, this is probably caused by non-English locales used on servers. – Peter Zaitcev Aug 18 '22 at 12:02
  • 1
    I commented out "Match Group Administrators", enabled "PubkeyAuthentication yes", then restarted service "ControlPanel>AdministratorTools>Services>sshd", finally works, thanks. – Ömer Sezer Jan 11 '23 at 17:45
5

This is just my scripted version of @n0rds great answer.

Place this script in a directory w/ your private/public key/pair and run!

PowerShell.exe -ExecutionPolicy Bypass -File "C:\bypass\prompt\standard.ps1" 2>&1>$null

Add-WindowsCapability -Online -Name OpenSSH.Server
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH SSH Server' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 -Program "%WINDIR%\System32\OpenSSH\sshd.exe"

#Must Enable ssh-agent before starting
Set-Service -Name ssh-agent -StartupType Automatic
Set-Service -Name sshd -StartupType Automatic
Start-Service ssh-agent; Start-Service sshd

$sshdir="$env:USERPROFILE\.ssh"
mkdir $sshdir
copy .\id_rsa $sshdir\
cat  $sshdir\id_rsa
copy .\*.pub  $sshdir\authorized_keys
cat $sshdir\authorized_keys
ssh-add $sshdir\id_rsa

$sshd_config="C:\ProgramData\ssh\sshd_config" 
(Get-Content $sshd_config) -replace '#PubkeyAuthentication', 'PubkeyAuthentication' | Out-File -encoding ASCII $sshd_config
(Get-Content $sshd_config) -replace 'AuthorizedKeysFile __PROGRAMDATA__', '#AuthorizedKeysFile __PROGRAMDATA__' | Out-File -encoding ASCII $sshd_config
(Get-Content $sshd_config) -replace 'Match Group administrators', '#Match Group administrators' | Out-File -encoding ASCII $sshd_config
cat C:\ProgramData\ssh\sshd_config

Restart-Service ssh-agent; Restart-Service sshd

Write-Host "Use this to Login/test Now"
write-host ssh $env:UserName@localhost
FreeSoftwareServers
  • 2,271
  • 1
  • 33
  • 57
3

If you are using mls-software.com's version of OpenSSH here is another note.

If you install using the SSHD_SERVER account and privilege separation you will be able to use public key authentication (per http://www.mls-software.com/opensshd-pki.html). However if UAC is enable you will not be successful with the install. The user(s) will not be created properly and the service will not be created. Manually trying to get these items up after the fact is very difficult. Simply disabling UAC before installation will allow the installation process to properly create the user(s) and the service. After installation you can re-enable UAC.

When I created the SSHD_SERVER account manually authentication succeed when using password authentication but the client termination the connection with "/bin/bash: Operation not permitted". Authentication with public keys was closed by the server (original error posted by Cambolie).

Dustin
  • 81
  • 4
  • Feedback from mls-software, points that this is not always the case. Disabling UAC in my case worked around the issue but it may not be necessary in all instances. I will look into my situation more and see if I can post more details. – Dustin Nov 05 '14 at 13:09
  • Why does it matter for MLS OpenSSH? Why can't it run as Local System (or some other, even domain, account?) – Mikhail Orlov Jun 12 '15 at 10:55
1

I solved it by:

  1. Installing in SSHD_SERVER + privilege separation mode. I also set privilege separation to "yes" in the config manually. This didn't work for me for a lot time, the user didn't get created. Then it worked, I don't know why. I only went to user accounts in control panel to check that UAC is off. I also had /var/empty with full access for everyone.
  2. For C:\openssh\var\empty I've set "attributes get/set" permissions to Everyone and myself and "full" permissions to .\sshd_server. I also made it the owner.
Mikhail Orlov
  • 2,789
  • 2
  • 28
  • 38
1

I ran into a different situation.

First, debug as gWay said, with another terminal windows connecting to the server.

I gotread_keyfile_line: C:\\Users\\yieatn\\.ssh/authorized_keys line 1 exceeds size limit

recode the authorized_keys into utf-8

The reason is that I created authorized_keys with cat id_rsa >> authorized_keys and powershell in Chinese uses UTF-16 to create files.

isudfv
  • 179
  • 1
  • 9
0

I've thoroughly tested n0rd's solution on multiple Windows Pro 1809 and 2004 computers. I concur with most of his steps.

Server setup (elevated PowerShell): Agree with all.

Client setup (non-elevated PowerShell): Agree with all.

Server setup continued (non-elevated PowerShell): Steps 1,2,3: Agree

Server setup continued (non-elevated PowerShell): Step 4: Do NOT perform anything in step 4.

Server setup continued (non-elevated PowerShell): Step 5: Agree

Server setup continued (non-elevated PowerShell): Step 6: (added) Uncomment (remove #) from C:\ProgramData\ssh\sshd_config: #PasswordAuthentication yes

Server setup continued (non-elevated PowerShell): Step 7: (added) In Services, restart OpenSSH SSH Server.

I did not find any issues, with any file, regarding security, permissions or Unicode. They were all correct out of the box.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
BSalita
  • 8,420
  • 10
  • 51
  • 68
  • I'm using Win 10.0.18363, but I was unable to get key-based authentication work. I can connect by using Password, but when switching to key based, I get Connection reset by ::1 port 22 even from localhost – ShiraishiMai Sep 23 '21 at 14:43
0

This is a very English language centric default Microsoft use. The group match lines currently check for the ENGLISH language version string of the Administrators group called 'administrators' this FAILS on many other language installs of windows. On a German installation that line needs to be 'administratoren' instead. They better make it possible le to match group by SID instead. ( This is even more important in the DenyGroups matching feature - have not tested this yet - but if they check for strings instead of SID there then the denies are meaningless and easily circumvented by using a different windows language install )

( also see https://github.com/MicrosoftDocs/windowsserverdocs/issues/1911#issuecomment-771552030 )

0

I couldn't get it to work with my ed25519 client public key (ssh-keygen -t ed215519) but it does work with an rsa key ( ssh-keygen -t rsa).

Jeffrey Knight
  • 5,888
  • 7
  • 39
  • 49
0

No one has pointed out that the file ~/.ssh/authorization_keys must use DOS/Windows line endings. It won't work with Unix line endings. If you have tried everything and still not working, try this (I am using cygwin):

gawk -v ORS='\r\n' '1' authorized_keys > authorized_keys2

Check that the file has now DOS line endings:

hexdump -C authorization_keys2

Replace the original file:

mv authorized_keys2 authorized_keys
James Risner
  • 5,451
  • 11
  • 25
  • 47
drone
  • 1