https://xeiaso.net/blog/yubikey-ssh-key-storage Xe - Blog - Contact - Gallery - Resume - Talks - Signal Boost - Feeds | GraphViz - When Then Zen How to Store an SSH Key on a Yubikey A 3 minute read. SSH keys suck. They are a file on the disk and you can easily move it to other machines instead of storing them in hardware where they can't be exfiltrated. Using a password to encrypt the private key is a viable option, but the UX for that is hot garbage. It's allegedly the future, so surely we MUST have some way to make this all better, right? Numa is delet >implying there is a way to make anything security related better Luckily, there is actually something we can do for this! As of OpenSSH 8.2 (Feburary 14, 2020) you are able to store an SSH private key on a yubikey! Here's how to do it. Mara is hacker This should work on other FIDO keys like Google's Titan, but we don't have access to one over here and as such haven't tested it. Your mileage may vary. We are told that it works with the Google Titan key that is handed out to Go contributors. First install yubikey-manager (see here for more information, or run nix-shell -p yubikey-manager to run it without installing it on NixOS), plug in your yubikey and run ykman list: $ ykman list YubiKey 5C NFC (5.4.3) [OTP+FIDO+CCID] Serial: 4206942069 If you haven't set a PIN for the yubikey yet, follow this to set a PIN of your choice. Once you do this, you can generate a new SSH key with the following command: ssh-keygen -t ed25519-sk -O resident Mara is hacker If that fails, try ecdsa-sk instead! Some hardware keys may not support storing the key on the key itself. Then enter in a super secret password (such as the Tongues you received as a kid when you were forced into learning the bible against your will) twice and then add that key to your agent with ssh-add -K. Then you can list your keys with ssh-add -L: $ ssh-add -L [email protected] AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIKgGePSwpBuHUhrFCRLch9Usqi7L0fKtgTRnh6F/R+ruAAAABHNzaDo= [email protected]achi Then you can copy this public key to GitHub or whatever and authenticate as normal. The private key is stored on your yubikey directly and you can add it with ssh-add -K. You can delete the ssh key stub at ~/.ssh/id_ed25519_sk and then your yubikey will be the only thing holding that key. --------------------------------------------------------------------- Share on Mastodon This article was posted on M05 27 2022. Facts and circumstances may have changed since publication. Please contact me before jumping to conclusions if something seems wrong or unclear. Series: howto Tags: yubikey security This post was WebMentioned at the following URLs: * Storing SSH keys on the Yubikey is great, especially since it's easy to use across machines and it never gets exposed on a machine. I would recommend a backup on e.g. an encrypted USB or on a second Yubikey tho :) * POG NEW DOMAIN LETS GOOOOOO * How to Store an SSH Key on a Yubikey christine.website/blog/ yubikey-s... #howto #yubikey #security *

@cadey I just wish the hardware tokens made it easier to store multiple keys (but yeah difficult with a single button interface)

I followed the opsec advice of "don't reuse keys" and now I have 70 different keys for different hosts and can't decide if it's better to have N different yubikeys I need to carry around or go back to a single key that gets reused everywhere.

*

I think I just want FIDO for ssh; something that will only send the right key to the right host ever, based on requesting domain & on-key secrets (or something. idk.)

* It's not really a very long article ^^ The art for Mara was drawn by Selicre. The art for Cadey was drawn by ArtZora Studios. --------------------------------------------------------------------- Copyright 2012-2022 Xe Iaso (Christine Dodrill). Any and all opinions listed here are my own and not representative of my employers; future, past and present. Like what you see? Donate on Patreon like these awesome people! Looking for someone for your team? Take a look here. Served by /nix/store/8fm0mqi15c7v9l6c5s14zwfijaiz7h3w-xesite-2.4.0/ bin/xesite, see source code here.