Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use public key authentication to login a ssh-server on WINDOWS?

I'm trying to login to my desktop's WSL from my laptop. I have installed the ssh-server (sshd) service (on Windows 10) and I was testing it. I successfully login the ssh with password by ssh <username>@localhost. Then I tried to get rid of the password and failed. When I enable both of password and pubkey authentication, password is always required.

When I just enable pubkey authentication, I got <username>@localhost: Permission denied (publickey,keyboard-interactive).. I find the log in Event Viewer: sshd: Connection reset by authenticating user <username> 127.0.0.1 port 9931 [preauth].

I have tried to use ssh -i .ssh/id_rsa.pub <username>@localhost to ensure the public key is correctly read by ssh client. I have tried to generate authorized_keys by the command from Key-based authentication in OpenSSH for Windows: User key generation. But I still cannot confirm whether the authorized_keys file is correctly configed. (I know that my problem may be solved by chmod 700 in Linux, but I have no idea about Windows)

like image 290
Frank Qiu Avatar asked Sep 15 '25 09:09

Frank Qiu


1 Answers

I just solved the problem after I checked sshd_config again and agian. I hope this problem doesn't waste more people's time so I opened this question.

It's a stupid problem. The solution is just delete the last 2 lines in sshd_config:

Match Group administrators
   AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys

I did not find any description of this configuration from Microsoft Documentation because it just gives link of original manual and the configuration is unique to Windows.

The problem is asked on Github but it is not fixed.

like image 68
Frank Qiu Avatar answered Sep 17 '25 07:09

Frank Qiu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!