Skip to content
September 29, 2009 / Kamil Páral

Command-line access to GNOME keyring

gnome-keyringA 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: :)

https://launchpad.net/gkeyring

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!

About these ads

9 Comments

Leave a Comment
  1. Name / Feb 1 2012 17:10

    Works like a charm, thanks!

  2. Den / Aug 14 2012 09:44

    Great! Thanks!

  3. Sander / Mar 7 2013 12:24

    thanks!

  4. Make A Facebook / Mar 8 2013 14:56

    Hi, Neat post. There’s a problem along with your website in web explorer, would check this? IE still is the market leader and a big element of other people will leave out your wonderful writing because of this problem.

    • Kamil Páral / Mar 8 2013 15:37

      Thanks for info, but this is hosted at WordPress, I don’t manage it. So please report all IE-related problems to WordPress, if you so desire. Personally I don’t care much, IE users and Linux users are quite disjoint groups.

Trackbacks

  1. Kamil Páral: Command-line access to GNOME keyring | TuxWire : The Linux Blog
  2. Command-line access to GNOME keyring « Kparal's RedHat Blog | Just linux!
  3. SVN in shell scripts - automating passwords
  4. Ubuntu One “DBus UnknownMethod” Error Fix

Leave a Reply (Markdown syntax supported)

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 26 other followers

%d bloggers like this: