linux:security:keyring
This is an old revision of the document!
Table of Contents
Linux Keyring
keyring
Python-Keyring command-line utility: https://pypi.org/project/keyring/
Install
sudo apt install python3-keyring
Description
From man keyring
keyring provides a way to store, lookup and delete passwords in various backends supported by Python-Keyring.
Usage
Python
You can set/get entries from a Python script or from the Python terminal
Add an entry
keyring.set_password("system", "username", "password")
# Same as above but ask for the password
keyring.set_password('twitter', 'xkcd', getpass.getpass())
Get a password
keyring.get_password("system", "username")
CLI
You can set/get entries directly from the command line or from bash scripts, etc.
keyring --help keyring set SERVICE USERNAME keyring get SERVICE USERNAME keyring del SERVICE USERNAME
Details
The commands above will set the following attributes on an entry:
- For example, running:
keyring set twitter chuckn246
- Will create an entry with the Title:
- Password for 'chuckn246' on 'twitter'
- Will set these attributes on the entry:
- application: Python keyring library
- service: twitter
- username: chuckn246
Small Gotcha
- Note that the attribute username is different than the entry UserName (Note capitalization).
secret-tool search service twitter [/org/freedesktop/secrets/collection/TestDB/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] label = Password for 'chuckn246' on 'twitter' secret = twitterpassword created = 2020-05-08 22:17:06 modified = 2020-05-08 22:17:06 schema = (null) attribute.Path = /Password for 'chuckn246' on 'twitter' attribute.Uuid = 3174d145b5e74435ab15cf45a5d805cb attribute.UserName = chuck attribute.service = twitter attribute.URL = attribute.Notes = attribute.application = Python keyring library attribute.username = chuckn246 attribute.Title = Password for 'chuckn246' on 'twitter'
linux/security/keyring.1590420634.txt.gz · Last modified: by chuck
