Menu
Anti-random
  • Contact Us
Anti-random

File based SSH keys and agent forwarding in Windows and WSL

Posted on June 1, 2020September 29, 2022 by Sid

This is a follow-up to the hardware based SSH keys post, to document the reverse i.e. from hardware SSH keys to file-based SSH keys. File based SSH keys are weaker since they’re on your hard drive in the clear but they are also convenient.

Windows 10

  1. Disable automatic startup of start wsl-ssh-pagent.bat if you added that from the previous blog post.
    Start -> type ‘startup’ -> Startup Apps -> scroll to start wsl-ssh-pagent.bat -> Toggle off.
  2. You may need to update the OpenSSH binaries shipped in Windows 10 since even the Windows 10 v20.04 binaries can give an agent returned different signature type error sometimes.
    • Download and unzip the file from https://github.com/PowerShell/Win32-OpenSSH/releases. I used the OpenSSH-Win64.zip file.
    • Open an elevated PowerShell terminal by start -> type ‘powershell’ -> right click -> run as administrator
    • Navigate to the folder where you extracted the files above and install by running the script .\install-sshd.ps1
  3. Make sure you do NOT have the environment variable SSH_AUTH_SOCK defined. Type $env:SSH_AUTH_SOCK and hit enter in a powershell terminal. If it’s undefined, you should see no output, good!
  4. Hit Start -> type “services” -> scroll to “OpenSSH Authentication Agent”. It should have status “Running” and Startup type “Automatic”.

WSL (Windows Subsystem for Linux)

  1. Open a WSL terminal
  2. nano ~/.profile
  3. add { eval ssh-agent; ssh-add /path/to/my/key; } &>/dev/null at the end
  4. comment or remove export SSH_AUTH_SOCK=/mnt/c/tools/wsl-ssh-pageant/wsl-ssh-agent.sock (or similar) if you had previously added it

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

©2023 Anti-random | Powered by WordPress & Superb Themes