Generate Google Service Account tokens with your YubiKey
Project description
google-yubikey
Generate Google Service Account tokens with your YubiKey!
Motivation
This is perhaps the most secure way to use Google credentials outside of Google Cloud, since the private key never leaves the device, and so it cannot be leaked or stolen without physically stealing the YubiKey.
Additionally, each operation is protected with a YubiKey PIN, providing a 2nd factor of authentication as something a user knows (in addition to something a user has, which is the YubiKey itself).
In this way, a single YubiKey can represent the identity of a user across many Service Accounts, without the need to send the private key material over the wire at any point.
This makes it even more secure than Service Account impersonation, where a user's long-term refresh token has been traditionally stored on their machine, and could thus be compromised.
Requirements
YubiKey 4+
Setup
pip3 install google-yubikey
Usage
-
Set up YubiKey PIN, as explained here.
-
Run this only once to set up a private key on the YubiKey, or to renew it after expiration:
google-yubikey generate-key > yubikey.pem
-
Install Google Cloud SDK and run:
gcloud auth login gcloud beta iam service-accounts keys upload yubikey.pem \ --iam-account <service_account_email> gcloud auth revoke # optional, but recommended
This is needed only for setting up YubiKey with a Service Account. Your user account must have at least
Service Account Key Admin
role oriam.serviceAccountKeys.create
permission on the target Service Account(s).As a good practice, the last command revokes your Google Cloud SDK credentials, which limits the potential for their exposure only to the time of the public key upload.
Alernatively to step 3, you can upload
yubikey.pem
from step 2 via Google Cloud Console for the target Service Account(s). -
Run this every time you'd like to generate a Service Account token:
google-yubikey token -a <service_account_email>
-
Further customization options are available through:
google-yubikey [<command>] -h
Disclaimer
This tool is still early on in the development. It works, but may have unusual edge cases that make it fail for your setup. Please use with caution, and raise an issue if you come across one.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file google-yubikey-0.3.0.tar.gz
.
File metadata
- Download URL: google-yubikey-0.3.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.3.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07beef085bc89cfae7892fa375c78f8f4cbe1c2bed7b5ff44c0c3fed19674adb |
|
MD5 | 301f0708be6a4bfc8383a7b84136ceba |
|
BLAKE2b-256 | 1f015f03e03bce287ba94a925681f73b257237e1605fd446ea279d05fbaf7737 |
File details
Details for the file google_yubikey-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: google_yubikey-0.3.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.3.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 534924998de104b97a660678f742b1818578a71dc139a37e81f90b4f9af06e54 |
|
MD5 | a7643afc7ade21e9c5322e73bc6115e9 |
|
BLAKE2b-256 | 051951d2920b9416c98bdd97f01bf6a26aeb8faa5856f310955c3589c5134396 |