Note that on larger installations, it is useful to put predefined files into the directory /etc/skel/.gnupg so that newly created users start up with a working configuration.
gpg--list-secret-keys--keyid-formatLONG
# export/backup and restoring (https://www.howtogeek.com/816878/how-to-back-up-and-restore-gpg-keys-on-linux/)
gpg--export--export-optionsbackup--outputpublic.gpg[user@email.com]
gpg--export-secret-keys--export-optionsbackup--outputprivate.gpg
gpg--export-ownertrust>trust.gpg
# restore backup/import
gpg--importpublic.gpg
gpg--importprivate.gpg
gpg--import-ownertrusttrust.gpg
# [read key ID from key without import](https://security.stackexchange.com/questions/43348/extracting-the-pgp-keyid-from-the-public-key-file)
gpg--dry-run--import--import-optionsshow-onlypubkey.gpg
# receive public key from keyserver
gpg--recv-keys$fingerprint# Retrieve key from keyserver
wgethttps://host.domain.tld/<keyfile>
file<keyfile>
# gpg supports a number of key formats, so if your key is in a different format, convert it by importing it into a temp keyring, then exporting it again:
gpg--no-default-keyring--keyring./temp-keyring.gpg--import<keyfile>
gpg--no-default-keyring--keyring.*/temp-keyring.gpg--export--output/usr/share/keyrings/<keyfile>.gpg
rmtemp-keyring.gpg
# For ASCII type keys do it in this form:
wget-O-https://example.com/key/repo-key.gpg|gpg--dearmor|sudotee*/usr/share/keyrings/*<myrepository>-archive-keyring.gpg
# or
curl[<https://example.com/key/repo-key.gpg>](https://example.com/key/repo-key.gpg)|gpg--dearmor>*/usr/share/keyrings/*<myrepository>-archive-keyring.gpg
# For non-ASCII type keys do it in this form:
wget-O-[<https://example.com/key/repo-key.gpg>](https://example.com/key/repo-key.gpg)|sudotee*/usr/share/keyrings/*<myrepository-archive-keyring.gpg>
# Or you can get your keys from a keyserver like so:
sudogpg--no-default-keyring--keyring*/usr/share/keyrings/*<myrepository>-archive-keyring.gpg--keyserver<hkp://keyserver.ubuntu.com:80>--recv-keys<fingerprint>
# All keys will be stored in */usr/share/keyrings/* folder. You can use those keys when you add your repo with the signed-by option to your sources.list file:# deb [signed-by=*/usr/share/keyrings/*<myrepository>-archive-keyring.gpg] [<https://repository.example.com/debian/ stable main>](https://repository.example.com/debian/stablemain)# Or you can add the arch=amd64 in the same fashion:# deb [arch=amd64 signed-by=*/usr/share/keyrings/*<myrepository>-archive-keyring.gpg] [<https://repository.example.com/debian/ stable main>](https://repository.example.com/debian/stablemain)# Deprecated
wget-qO-[http://example.com/archive.key](http://example.com/archive.key)|apt-keyadd-
apt-keyadv--keyserverkeyserver.ubuntu.com--recv-keysE084DAB9