Files
ephemere/bash/yubikey/list-yubikey-ssh-keys.sh
T
hikari b0620f2af3 refactor: reorganise bash scripts into subdirectories and add bash runner support
Move yubikey scripts from bash/ root into bash/yubikey/, move cohort shell
scripts from python/cohort/ into bash/cohort/, and update run.sh to support
Bash as a third language with category-based script discovery.
2026-02-23 20:00:44 -08:00

22 lines
832 B
Bash
Executable File

#!/bin/bash
echo "Scanning YubiKey slots for SSH keys..."
echo "---------------------------------------------------"
# Loop through the slots that support SSH keys
for SLOT in 9a 9c 9d 9e; do
# Try to export the key to a temp file
if ykman piv keys export $SLOT /tmp/yubi_tmp.pem > /dev/null 2>&1; then
echo -e "\033[0;32mFOUND KEY IN SLOT $SLOT:\033[0m"
# Check if there is a certificate label
LABEL=$(ykman piv certificates export $SLOT - 2>/dev/null | openssl x509 -noout -subject 2>/dev/null)
if [ ! -z "$LABEL" ]; then
echo "Certificate Label: $LABEL"
fi
# Convert to SSH format and print
ssh-keygen -i -m PKCS8 -f /tmp/yubi_tmp.pem
echo "---------------------------------------------------"
rm /tmp/yubi_tmp.pem
fi
done