GitHub CLI has introduced short-lived access tokens to improve security, but the tool ghtkn offers enhanced protection by securing refresh tokens within an encrypted, passphrase-protected local daemon.
Key Points
- GitHub CLI (gh) now uses short-lived access tokens that automatically refresh, though refresh tokens remain stored in the OS keyring.
- The ghtkn CLI utilizes a local agent backend that encrypts refresh tokens with a user-defined passphrase, preventing unauthorized access by other processes.
- Unlike the GitHub CLI, ghtkn allows users to restrict token access to specific organizations and repositories using GitHub App user access tokens.
- The ghtkn agent can be manually locked to prevent token generation, and it provides alerts if a refresh token is potentially compromised.
- ghtkn supports switching between multiple GitHub Apps with varying permission levels, reducing the risk associated with overly privileged tokens.