How to restore SSH keys on Windows 11
I'm writing this as a note to future self. I find myself using a Windows 11 laptop as my daily driver and I'd like to write some blog posts. I use Eleventy for my blog and Capsul to host it as a VPS. I need to be able to SSH to the VPS, which means I need to restore my SSH keys from one of my Linux workstations. Here are the steps I researched and followed to get up and running.
-
Locate backup of SSH keys.
id_ed25519
(Important: This is the private key so should be considered confidential and secure.)id_ed25519.pub
-
The computer I'm using already had
%userprofile%\.ssh
directory but if it's not there, create it. -
Copy the SSH key files to
%userprofile%\.ssh
. -
Execute the following PowerShell commands:
Get-Service ssh-agent | Set-Service -StartupType Automatic Start-Service ssh-agent ssh-add c:\users\obsolete29\.ssh\id_ed25519
-
That gave me the following error message:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions for 'C:\\users\\michael' are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored. harley\.ssh\id_ed25519: No such file or directory
-
I used File Explorer to remove the permissions on the .ssh folder so that only I had access to it. I then re-ran the ssh-add command and it worked.