How to Store SSH Keys on Password Managers
A tool to manage and store your SSH keys on password managers 1Password, Bitwarden and AWS S3
Introduction
Managing SSH keys are hard. Especially if you would like to move them to different devices, or sharing the same keys across devices add more complexity. In order to solve this problem, I created SSH Manager to allow other developers to manage their keys on their favourite password managers securely.
SSH Managers supports only 1Password and Bitwarden at the moment, but more managers are on the way.
Prerequisites
Before you get started, you will need to have a number of things.
- Go
- Have the Bitwarden CLI tool installed and available in the
$PATHasbw. - Or have the 1Password CLI tool installed and available in the
$PATHasop. - Have the
ssh-agentrunning in the current session.
Installing SSH Manager Binary
In order to be able to run ssh-manager, we need to install the binary to the
local machine. For this, run the following go command to get the package.
go install github.com/omegion/ssh-manager@latestLet’s test that the binary is working:
ssh-manager --helpIf everything went well, you will see the CLI help as below:
❯ ssh-manager --help
CLI command to automatically unseal Vault
Usage:
vault-unseal [command]
Available Commands:
add Add Manager key to given provider.
get Get Manager key from given provider.
help Help about any command
list List Manager keys from given provider.
version Print the version/build number
Flags:
-h, --help help for vault-unseal
--logFormat string Set the logging format. One of: text|json (default "text") (default "text")
--logLevel string Set the logging level. One of: debug|info|warn|error (default "info")
Use "vault-unseal [command] --help" for more information about a command.Generate Test SSH Keypair
Before using your SSH keys to store in Bitwarden, let’s create a dummy keypair and test with it.
- Open Terminal.
- Paste the command below
ssh-keygen -t ed25519 - When you’re prompted to “Enter a file in which to save the key,” enter
test. - At the prompt, do not type a secure passphrase.
Add SSH Keys
Let’s be sure that we have previously created keys:
❯ ls -l test*
-rw------- 1 X staff 432 Mar 30 08:38 test
-rw-r--r-- 1 X staff 112 Mar 30 08:38 test.pubI will use Bitwarden as a password manager for this example. Now we can add them to Bitwarden.
ssh-manager add --name test --private-key test --public-key test.pub --provider bwGet SSH Keys
Once we have SSH keypair on Bitwarden, let’s get them to our local machine.
❯ ssh-manager get --name test --provider bw
SSH Key test added.Let’s check ~/.ssh/keys folder if our keys are added.
❯ ls -l ~/.ssh/keys/
-rw------- 1 X staff 432 Mar 30 11:05 test
-rw------- 1 X staff 112 Mar 30 11:05 test.pubConclusion
In this tutorial, we generated SSH keypair and store them in a password manager,
in this case, we used Bitwarden. Then we used SSH Manager to get the SSH keys to
the local machine and add them to ssh-agent.