Justfile: add commands to switch yubikey

This commit is contained in:
steveej 2019-07-17 09:46:38 +02:00
parent 2f5c911da4
commit 8ce1ea2e9d

View file

@ -241,3 +241,17 @@ run-with-channels +cmds:
#!/usr/bin/env bash #!/usr/bin/env bash
source $(just -v _get_nix_path {{invocation_directory()}}/nix/variables/versions.nix) source $(just -v _get_nix_path {{invocation_directory()}}/nix/variables/versions.nix)
{{cmds}} {{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