- 1 year ago
How to store the Credentials/Important information in Ubuntu like we do in Windows Credentials Manager?
In Ubuntu, you can use the secretservice
library to store sensitive information such as passwords and API keys. The secretservice
library is part of the gnome-keyring
package.
To store a secret using secretservice
, you can use the python3-keyring
library, which provides a simple interface to the secretservice
API.
Here's an example of how to store a secret using python3-keyring
:
pythonimport keyring
keyring.set_password('system', 'username', 'password')
In this example, system
is the name of the keyring you want to use, username
is the name of the credential you want to store, and password
is the value of the credential.
You can then retrieve the credential later using the get_password
function:
pythonpassword = keyring.get_password('system', 'username')
This will retrieve the value of the credential stored in the system
keyring with the name username
.
Note that you will need to have the gnome-keyring
package installed in order to use secretservice
. You can install it using the following command:
arduinosudo apt-get install gnome-keyring