Skip to content

Instantly share code, notes, and snippets.

View nihilne's full-sized avatar
💤
definitely sleeping

nihilne

💤
definitely sleeping
  • 00:59 (UTC +02:00)
View GitHub Profile
@adamelliotfields
adamelliotfields / windows-ssh-no-password-with-keys-wsl2.md
Last active January 24, 2026 15:30
Windows SSH Server with Password-less Key Authentication and Default WSL2 Shell

I wanted to be able to SSH into my Windows laptop directly into Linux. I also wanted to disable password authentication and only allow public key (RSA in my case) authentication.

Scott Hanselman wrote a blog post on how to make your default WSL2 distro your default shell for SSH. Windows OS Hub published an article on using public key authentication. These were both helpful resources.

I'll assume you're already familiar with using SSH keys. If not, this article at DigitalOcean is very informative.

Add your public key to your authorized keys file

First thing you want to do is create the file $HOME\.ssh\authorized_keys. If you run into issues, it could be due to incorrect file ownership.