Setting up 1Password SSH on Windows

Setting up 1Password SSH on Windows

6th of February 2024

Edited: 24th of February 2024

titbidgitssh

Setting up 1Password SSH on Windows

I’m using 1Password to store my SSH keys so its easy to move them between PCs ever since 1Password made it possible to use them directly without having to copy them. But I have had problems making this work with terminals, Git Bash and more.

So this article will go through my findings on how to set up 1Password SSH for Windows to use with Windows Terminal and Git Bash.

Some of the information here can also be found on 1Passwords own getting started guide: https://developer.1password.com/docs/ssh/git-commit-signing/

These are the steps

  1. Start the SSH agent in 1Password
  2. Make sure git also uses correct SSH agent by setting the sshCommand in the global git config
  3. Alias ssh in Git Bash’ .bash_profile to use OpenSSH

The issue

When 1Password is installed, the SSH agent started and SSH keys added it doesn’t always just work out of the box; at least not on Windows, where I’ve used it.

Git might use their own built-in SSH agent instead of Windows OpenSSH, which is what 1Password augments with its stored SSH keys.

Furthermore, if you use Git Bash it also might not use the correct SSH agent, when using the SSH command, but we can fix that too.

Enable 1Password SSH agent

In the 1Password desktop app the SSH agent can be enabled from the settings under the Developer section.

The 1Password Developer settings tab

Set Git to use correct SSH agent

To make sure that git uses the correct ssh client when connecting to for instance GitHub we can set the sshCommand value in the global git config.

Add sshCommand = "C:/Windows/System32/OpenSSH/ssh.exe" under the [core] section. The global git config file (.gitconfig in user folder) should then look something like this:

[core]
  sshCommand = "C:/Windows/System32/OpenSSH/ssh.exe"

This can also be set using the command: git config --global core.sshCommand "C:/Windows/System32/OpenSSH/ssh.exe".

Alias ssh in Git Bash

If you are using Git Bash and want to be able to use the SSH command directly you can alias the ssh command to point to the Windows OpenSSH.

To do this, you need to either find your existing .bash_profile file (which is usually found in your user folder) or create it.

In .bash_profile file add the following:

alias ssh='/c/Windows/System32/OpenSSH/ssh.exe'

Outro

I hope this guide helps you solve the issues that I found, when setting up SSH with 1Password.

I’ve also collected a few useful links below for further reading.

When you’ve set up SSH with 1Password, you can also go further and sign Git commits with your SSH key.

1Password has a guide to set this up: https://developer.1password.com/docs/ssh/git-commit-signing/

If you are using WSL on Windows, there is also a guide on how to set that up on their website: https://developer.1password.com/docs/ssh/integrations/wsl


Phillip Phoelich

6th of February 2024

Back to blog