Quantcast
Channel: Where should we locate authorized_keys when we use Windows 10 OpenSSH server and WSL2? - Super User
Viewing all articles
Browse latest Browse all 2

Where should we locate authorized_keys when we use Windows 10 OpenSSH server and WSL2?

$
0
0

I set up Windows 10's OpenSSH server to establish a ssh connection to WSL2's bash by a method described in this article: "THE EASY WAY how to SSH into Bash and WSL2 on Windows 10 from an external machine", and this document: "OpenSSH key management".

In summary, I run the following commands on PowerShell as admin:

Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0Start-Service sshdNew-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\WINDOWS\System32\bash.exe" -PropertyType String -Force

After that, I could connect by ssh from PowerShell to WSL2's bash on localhost by ssh <my Windows username>@localhost using Windows' password.

Next, I want to connect not using a password, but using a key pair. So I created a key pair on PowerShell and located it as C:\Users\<my Windows username>\.ssh\authorized_keys.

cd C:\Users\<my Windows username>\.sshssh-keygen -t ed25519 -f id_ed25519copy id_ed25519.pub authorized_keys

But this could not allow me to connect localhost using the key pair. A command ssh -vvv -i C:\Users\<my Windows username>\.ssh\id_ed25519 <my Windows username>@localhost returns a permission error with a log line debug3: receive packet: type 51 just after offering public key of the private key.

As another try, I located the authorized_keys in WSL2's home directory /home/<my WSL2 username>/.ssh and run chmod 600, but the result of ssh on PowerShell is the same as above.

So my question is: How to connect the OpenSSH server on Windows 10 whose default shell is WSL2's bash, using a key pair? Where should I locate authorized_keys?


Viewing all articles
Browse latest Browse all 2

Trending Articles