KEY_ID='[email protected]'
cat <<EOF >"${KEY_ID}...pub+sec.asc" \
&& gpg --output "${KEY_ID}...pub.gpg" \
--export ${KEY_ID} \
&& gpg --output - \
--export-secret-keys \
--export-options export-backup \
${KEY_ID} \
| cat "${KEY_ID}...pub.gpg" - \
| gpg --armor \
--symmetric \
--cipher-algo aes256 \
>> "${KEY_ID}...pub+sec.asc"
uid: ${KEY_ID}
keys: public + secret
cipher: aes256
EOF
$ ls
[email protected]+sec.asc [email protected]
gpg --output - --decrypt "[email protected]+sec.asc" \
| gpg --import
Execute
gpg --output - --decrypt "[email protected]+sec.asc" \
| gpg --homedir /path/to/newGpgHome --import
Unload GnuPG Agent in case of gpg: error sending to agent
/ gpg: error reading '[stdin]'
errors:
gpg-connect-agent --homedir /path/to/newGpgHome killagent /bye
- Moving Gpg keys privately
- StackExchange answer for question ‘How to export a GPG private key and public key to a file?’
tags: gpg
, gnupg