A few days back I suddenly needed to access GNOME keyring from a command-line, to be used in my backup script. Of course I can save my passwords in plaintext in files like .netrc, but why should I, when all my passwords are already stored securely in the GNOME keyring? I have googled and googled and found nothing, there is no tool for accessing GNOME keyring from shell (until now). But I have found a simple Python module though (kudos to Sebastian Rittau).
I’m a complete beginner with Python, but I said ‘Hey, that’s a good opportunity to learn it a little bit!’. So I present you my outstanding result, the gkeyring project: 🙂
Retrieving your secrets is as simple as:
$ ./gkeyring.py get -s myserver.com -p ftp -u user
This will look for all keyring items concerning server myserver.com with protocol ftp and username user. Note: Currently the script is only able to access network passwords (which is what I needed).
The first time you access the keyring item you will be prompted whether to allow the script to access it. You can click “Always” and then it won’t ask again. Finally you just cut the output a little and you are done! Ready to be used in your script.
Hope that helps someone (it does help me). If you feel like improving the script, please do!