-
Notifications
You must be signed in to change notification settings - Fork 0
GPG
kamack38 edited this page Oct 5, 2025
·
6 revisions
gpg --full-generate-keygpg -k
gpg --output PublickKey.key --armor --export $KEY_IDgpg -K
gpg --output Secret.key --armor --export-secret-keys $KEY_ID
# Or subkeys
gpg --output Secret-Subkeys.key --armor --export-secret-subkeys $KEY_IDgpg --import ./private.keyRemember to delete the private.key file to not expose the key.
Read GitHub documentation about generating a new GPG key for more details.
gpg --keyserver keyserver.ubuntu.com --send-keys <key-id>gpg --export-ssh-key <key-id>You can view the whole Yubikey Guide at drduh/YubiKey-Guide.
- Fetching manually:
gpg --card-edit
gpg> fetch
gpg> quit- Fetching by automatically passing the fetch command (this will read the commands from stdin)
echo "fetch" | gpg --command-fd=0 --pinentry-mode=loopback --card-editgpg --expert --edit-key <key-id>
gpg> key 1
gpg> keytocard
# When moving a key remember to chose the correct slot
gpg> key 1
# Do the same for each key (remember to deselect it after moving it to card)
gpg> saveI haven't found a way to remove a key from a smartcard. The only way is to reset it to factory settings.
gpg --edit-card
gpg> admin
gpg> factory-resetYubikey defaults:
-
PIN:
123456 -
Admin PIN:
12345678
- To use GPG for SSH authentication you have to set the SSH socket. You can add the code below to
your
.bashrcfile
export GPG_TTY=$(tty)
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpgconf --launch gpg-agent
gpg-connect-agent updatestartuptty /bye > /dev/null- The ssh public SSH key can be exported using the command below
gpg --export-ssh-key <key-id>