Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This method is only suitable if you’re running in a desktop environment, such as MacOS, Windows, or Linux (Gnome). If you’re not running in a desktop environment, for example, a remote ssh terminal or cron job, please see https://tuftswork.atlassian.net/wiki/spaces/ESPTS/pages/640253962/Storing+Secrets#If-you-are-running-without-a-desktop

If desired, create a python virtual environment, and activate it. For example:

...

Code Block
python setsecret.py 
Set secret!

python getsecret.py 
Got secret mysecret

If you are running on a desktop system, such as your mac, windows, or linux gnome laptop, it should work, and it securely stores your secret using your user keyring, which is locked by your login session. But if you are running on a remote system via ssh, or a headless service account, or cron job, you may get this error message. The solution is to install keyrings.alt as describe below:get the following error message, most likely you’re not running in a supported desktop environment. Don’t use keyrings.alt. Instead, use a supported backend (follow the link in the error message), or use the method from https://tuftswork.atlassian.net/wiki/spaces/ESPTS/pages/640253962/Storing+Secrets#If-you-are-running-without-a-desktop

Note

keyring.errors.NoKeyringError: No recommended backend was available. Install a recommended 3rd party backend package; or, install the keyrings.alt package if you want to use the non-recommended backends. See https://pypi.org/project/keyring for details.

...

.

...

Code Block
pip install keyring keyrings.alt