Skip to content

Dear Internet Explorer user: Your browser is no longer supported

Please switch to a modern browser such as Microsoft Edge, Mozilla Firefox or Google Chrome to view this website's content.

Setting up SSH keys in 1Password for WSL2

Use the 1Password password manager to store your SSH keys to enable SSH access to GitHub and other servers that you work on in Windows Subsystem for Linux (WSL2).

In my previous post, I described how to set-up SSH keys in 1Password for Windows. You can take this one step further and enable it to work in Windows Subsystem for Linux (WSL2) as well.

There are a few tutorials available online which detail some rather complex methods that include installing multiple dependencies, but this is unnecessary.

Assuming that you have completed all of the steps in my previous tutorial, here are the steps for setting-up 1Password SSH key management in WSL2:

Step 1:

Install the 1Password CLI in Windows via winget:

winget install -e --id AgileBits.1Password.CLI

Step 2:

Test that Windows OpenSSH is reachable by running the following command in WSL2:

ssh-add.exe -l

If that command says command not found inside WSL, try the full path:

/mnt/c/Windows/System32/OpenSSH/ssh-add.exe -l

Step 3:

Get Git in WSL to use the Windows SSH client:

git config --global core.sshCommand ssh.exe

Step 4:

Create aliases in ~/.bashrc or ~/.bash_aliases

alias ssh='ssh.exe'
alias ssh-add='ssh-add.exe'

Step 5:

Check if Git in WSL2 will trigger the use of the 1Password.

ssh -T git@github.com
Dialogue box asking for a password
The 1Password access dialogue box should be displayed when attempting to access 1Password’s CLI.

After that, the normal 1Password dialogue box should be triggered when you interact with GitHub via SSH, or attempt to connect to any other server via SSH.

   

Comments

No comments have yet been submitted. Be the first!

Have Your Say

The following HTML is permitted:
<a href="" title=""> <b> <blockquote cite=""> <code> <em> <i> <q cite=""> <strike> <strong>

Comments will be published subject to the Editorial Policy.