Set and Retrieve Passwords From Your Systems Password Manager With The keyring Python Module
NOTE: See also this post:
#TL;DR
Set passwords form the command line with:
(NOTE: confirmed in march 2022 that PASSWORD_NAME USER_NAME is the proper order)
python3 -m keyring set PASSWORD_NAME USER_NAMERunning that will ask you to put in the password.
Then, retrieve them in scripts with:
NOTE: Confirmed that this is the order the parameters need to be in to get keys that were added from inside Keychain Access itself
# Details
You can store passwords in your system's credential locker (e.g. Keychain Access on macOs and ... on Windows and ... on Linux) with the keyring Python module.
Installation
Install it with either pip3 or pip depending on your configuration. E.g.
# Setting Passwords From Scripts
You can set your passwords in a script with:
# Setting Passwords From The Command Line
You can set passwords directly from the command line with:
- You'll be prompted to enter your password from there
# Retrieving Passwords
And retrieve them with:
# Notes
- As far as I can tell "SERVICE" is just for grouping. I simply use my username. - I used to add dates to my passwords, but I stopped doing that. (This is more a reminder to myself that to anyone else)
Note: if you put something directly in Keychain Access, the values you put in for name and account are used in a backwards order from what you'd expect. i.e.
TODO: Look at the below for setting them to see how it goes in and if it's reversed or not
TODO: Add a python command line version of using the module to add passwords