Skip to content

Instantly share code, notes, and snippets.

@andrewlkho
Last active October 12, 2022 03:50
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andrewlkho/6777065 to your computer and use it in GitHub Desktop.
Save andrewlkho/6777065 to your computer and use it in GitHub Desktop.
How to import a gpg secret subkey into an existing secret key
# The following example imports subkey DF6C5C29 into a secret keyring that
# already contains 55C794A2
% gpg --list-secret-keys
sec 4096R/AF72A573 2012-06-17
uid Andrew Ho <andrewho@andrewho.co.uk>
ssb 4096R/55C794A2 2012-06-17
% mkdir 55C794A2
% cd 55C794A2
% gpg --export-secret-key 55C794A2 | gpgsplit
% ls
000001-005.secret_key
000002-013.user_id
000003-002.sig
000004-013.user_id
000005-002.sig
000006-013.user_id
000007-002.sig
000008-007.secret_subkey
000009-002.sig
% cd ..
% gpg --delete-secret-and-public-keys AF72A573
% gpg --import ./DF6C5C29.asc
% gpg --list-secret-keys
sec 4096R/AF72A573 2012-06-17
uid Andrew Ho <andrewho@andrewho.co.uk>
ssb 4096R/DF6C5C29 2012-06-17
% mkdir DF6C5C29
% cd DF6C5C29
% gpg --export-secret-key DF6C5C29 | gpgsplit
% cd ..
% cp DF6C5C29/000008-007.secret_subkey 55C794A2/000010-007.secret_subkey
% cp DF6C5C29/000009-002.sig 55C794A2/000011-002.sig
% cat DF6C5C29/* > ./combined.asc
% gpg --delete-secret-and-public-keys AF72A573
% gpg --import ./combined.asc
% gpg --list-secret-keys
sec 4096R/AF72A573 2012-06-17
uid Andrew Ho <andrewho@andrewho.co.uk>
ssb 4096R/55C794A2 2012-06-17
ssb 4096R/DF6C5C29 2012-06-17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment