I see this in the help
keyring -h
usage: keyring [-h] [-p KEYRING_PATH] [-b KEYRING_BACKEND] [--list-backends] [--disable]
[operation] [service] [username]
positional arguments:
operation get|set|del
service
username
optional arguments:
-h, --help show this help message and exit
-p KEYRING_PATH, --keyring-path KEYRING_PATH
Path to the keyring backend
-b KEYRING_BACKEND, --keyring-backend KEYRING_BACKEND
Name of the keyring backend
--list-backends List keyring backends and exit
--disable Disable keyring and exit
However without remembering what I stored there a long time ago I can't figure out how to list the secrets stored there. What is the right command line for this ?
The keyring command line tool does not support that.
A feature request has been discussed in this thread (link) , but it has not been implemented.
It can get and set secrets in a variety of keychain services, including: KWallet, SecretService, Windows Credential Locker, etc. These are called backends.
In my case, on Ubuntu 22.04, the underlying default keychain tool is SecretService. I was able to get a list with the following Python code.
import secretstorage
conn = secretstorage.dbus_init()
collection = secretstorage.get_default_collection(conn)
for item in collection.get_all_items():
print('='*30)
print('label:', item.get_label())
print('attributes:')
for k,v in item.get_attributes().items():
print('\t%-12s: %s' % (k,v))
print('secret:',item.get_secret())
The keyring command line tool is just the command line part of a Python library https://github.com/jaraco/keyring.
With some Python knowledge you are able to use keyring to get such a list.
for item in keyring.get_keyring().get_preferred_collection().get_all_items():
print(item.get_label(), item.get_attributes())
However, I suspect it only lists the secrets for one backend (the default/preferred one), in my case SecretService. I assume most people only have one keychain service in use, but there might be cases where there is more than one.