I'd like to send my entire public keychain to a friend of mine (and back it up for obvious reasons) and would like to export it into one single block, like GPA does. Bonus points if it's signed with my own private key.
gpg --export without further filters exports all public keys including signatures. Apply the
--armor option if you want ASCII-armored output, and redirect output to a file. This command line exports all public keys to the
public-keys.gpg file in the ASCII-armored format:
gpg --armor --export > public-keys.gpg
It can be imported using the usual
gpg --import public-keys.gpg command.
Before GnuPG 2.1, you can also simply send the
~/.gnupg/pubring.gpg file, but this also includes "local" signatures that usually should not be exported. Since GnuPG 2.1 this is not possible any more, since the file also contains the private keys, and it is possible the keyring is in the keybox format instead (
If you want the file signed, you have to do this in a second step, like you would sign any other file:
gpg --sign public-keys.gpg