My scrapbook about anything which I learned or want to remember, Sometime about tech tips, thoughts and rambling. If you find anything useful don't forget to give thumbs-up :)

Breaking

Tuesday, October 1, 2024

Managing multiple GPG keyring

By default GPG command use the default keyring, pubring.kbx, to store/retrieve your gpg keys in the  system. Though, there can be multiple reasons why you want to manage multiple keyrings for your system, some of them are as below - 


 

Segregation of Keys:
You might want to segregate keys for different projects, purposes, or contexts to keep them organized and to limit access. For example, you could have separate keyrings for work-related keys and personal keys.

Temporary Key Storage:
If you receive a temporary key, such as a one-time-use key or a key for a single transaction, you might store it in a separate keyring to avoid cluttering your main keyring.

Testing and Development:
When developing applications that use GPG, you might want to use separate keyrings to avoid using production keys.

 

Creating New Keyring:
To create a new keyring is same as creating a new file. You can create them as below -

touch /path/to/your-keyring.gpg 
# or
gpg --no-default-keyring --keyring /path/to/your-keyring.gpg --fingerprint


Managing Multiple Keyrings
You can specify additional keyrings in GPG using command-line options. Here’s how you can work with them:

Listing Keys in a Specific Keyring
To list keys in a specific keyring, use the --keyring option followed by the name of the keyring file.
gpg --keyring /path/to/your-keyring.gpg --list-keys


Importing Keys into a Specific Keyring
To import keys into a specific keyring, again use the --keyring option.
gpg --no-default-keyring --keyring /path/to/your-keyring.gpg --import keyfile.asc


Exporting Keys from a Specific Keyring
To export keys from a specific keyring, specify the keyring with the --keyring option.
gpg --no-default-keyring --keyring /path/to/your-keyring.gpg --export -a > exported-keys.asc



No comments:

Post a Comment

Disclaimer

The postings on this site are my own and don't necessarily represent IBM's or other companies positions, strategies or opinions. All content provided on this blog is for informational purposes and knowledge sharing only.
The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site. The owner will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of his information.