authinfo-gpg
Read GPG-encrypted .authinfo.gpg credential files in Python.
Features
- Read encrypted
.authinfo.gpgfiles (netrc format) - Cross-platform GPG binary auto-detection
- Support for passphrase input or gpg-agent
- Simple, pythonic API
- No hardcoded paths or version dependencies
- Type-annotated
Installation
pip install authinfo-gpg
Requirements
- Python 3.7+
- GnuPG installed on your system
Quick Start
from authinfo_gpg import get_entry
from getpass import getpass
# Get passphrase from user
passphrase = getpass("Enter your GPG passphrase: ")
# Retrieve credentials
entry = get_entry(machine='example.com', login='myuser', passphrase=passphrase)
if entry:
print(f"Username: {entry.login}")
print(f"Password: {entry.password}")
Usage
Using the convenience function
from authinfo_gpg import get_entry
entry = get_entry('ollama.com', login='default', passphrase='my-gpg-pass')
if entry:
api_key = entry.password
Using the class interface
from authinfo_gpg import AuthInfoGPG
from getpass import getpass
# Initialize
auth = AuthInfoGPG()
# Get a specific entry
passphrase = getpass()
entry = auth.get_entry('example.com', passphrase=passphrase)
# Get all entries
all_entries = auth.get_all_entries(passphrase=passphrase)
for entry in all_entries:
print(f"{entry.machine}: {entry.login}")
Custom authinfo file location
from authinfo_gpg import AuthInfoGPG
auth = AuthInfoGPG(authinfo_path='/custom/path/to/.authinfo.gpg')
entry = auth.get_entry('example.com', passphrase='...')
File Format
The .authinfo.gpg file uses netrc format:
machine example.com login myuser password mypassword
machine api.service.com login admin password secret123 port 8080
Why authinfo-gpg?
The original authinfo package is unmaintained (last updated 2013, Python 2 only) and has compatibility issues with modern GnuPG installations. This package:
- Uses
subprocessto call GPG directly (more reliable) - Auto-detects GPG binary location (no hardcoded paths)
- Supports Python 3.7+
- Handles pinentry correctly with
--pinentry-mode=loopback - Actively maintained
Security Considerations
⚠️ Decrypted credentials and the GPG passphrase are held as plain Python strings in process memory until garbage-collected — Python provides no built-in mechanism to zero memory on deallocation. Avoid long-lived references to AuthEntry.password or the passphrase; retrieve credentials as close to their point of use as possible, and avoid storing them in module-level variables, caches, or data structures with unbounded lifetimes. On shared or multi-tenant systems, consider whether your threat model requires a language or runtime with explicit secure memory primitives.
License
MIT License - see LICENSE file for details
Contributing
Contributions welcome! Please open an issue or submit a pull request on GitHub.
Author
Armin Monecke authinfo-gpg@mnck.ai
Metadata
Release files for authinfo-gpg 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| authinfo_gpg-0.1.1.tar.gz | 7.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| authinfo_gpg-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.6 kB
Release files / authinfo_gpg-0.1.1.tar.gz
| Download URL | authinfo_gpg-0.1.1.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a508aa52c531baae5fa563f9f200c80739b09d73ef633cda3d62782e542bf130
|
|
BLAKE2b-256 checksum How to use checksums |
5082215948f6a314cfa59b068d591476df7c6a5b7b0a96e0969c8887ca2b7e7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Release files / authinfo_gpg-0.1.1-py3-none-any.whl
| Download URL | authinfo_gpg-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a976e471ccb7e4b5b02cede4b557d016dfd1ddb9f215091cecf9c5336176b73d
|
|
BLAKE2b-256 checksum How to use checksums |
6d09a13859a28cc70702cc98fe5dd4cc3956adde105e343a26537677c3d2731d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Security for authinfo-gpg 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.