From 8ce1ea2e9dd1fed0eb0b83a55daf95cb5f3940ed Mon Sep 17 00:00:00 2001 From: Stefan Junker Date: Wed, 17 Jul 2019 09:46:38 +0200 Subject: [PATCH] Justfile: add commands to switch yubikey --- Justfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Justfile b/Justfile index 4e1a4a1..6d13ff7 100755 --- a/Justfile +++ b/Justfile @@ -241,3 +241,17 @@ run-with-channels +cmds: #!/usr/bin/env bash source $(just -v _get_nix_path {{invocation_directory()}}/nix/variables/versions.nix) {{cmds}} + +# Switch between yubikeys which have a copy of the same key +switch-yubikey: + #!/usr/bin/env bash + # See https://github.com/drduh/YubiKey-Guide/issues/19 + set -xe + KEY_ID=$(gpg --card-status | rg sec | rg -o '[0-9A-Z]{16}') + gpg --delete-secret-and-public-keys $KEY_ID + gpg2 --edit-card <<-EOF + fetch + quit + EOF + gpg-connect-agent "scd serialno" "learn --force" /bye + gpg --card-status