How to merge 2 Gnome Password Keyrings?

When you remove the password from your keyrings, gnome keyring manager will save the files as clear text. You can edit those files with a text editor and copy the keys around. Set a password to have the keyring files encrypted again.

I suggest you backup your keyring files before doing this.

I assume you have two keyrings like this:

two keyrings

And the keyring files looking like this:

$ cd ~/.local/share/keyrings
$ file foo.keyring bar.keyring 
foo.keyring: GNOME keyring, major version 0, minor version 0, crypto type 0 (AEL), hash type 0 (MD5), name "foo", last modified Thu Jan  1 01:00:00 1970, created Thu Jan  1 01:00:00 1970, not locked if idle, hash iterations 1087, salt 10888099772058093604, 1 item(s)
bar.keyring: GNOME keyring, major version 0, minor version 0, crypto type 0 (AEL), hash type 0 (MD5), name "bar", last modified Thu Jan  1 01:00:00 1970, created Thu Jan  1 01:00:00 1970, not locked if idle, hash iterations 1749, salt 12972167437702069911, 1 item(s)

Remove the password from the two keyrings. To remove the password you have to change the password (right click > change password), enter the old password and leave the new password blank. A dialog will prompt you to verify that you want to store your passwords unencrypted.

Now your files should look like this:

$ file foo.keyring bar.keyring 
foo.keyring: ASCII text
bar.keyring: ASCII text
$ cat foo.keyring 

[keyring]
display-name=foo
ctime=0
mtime=0
lock-on-idle=false
lock-after=false

[1]
item-type=0
display-name=key1
secret=pass1
mtime=1311897928
ctime=0
$ cat bar.keyring 

[keyring]
display-name=bar
ctime=0
mtime=0
lock-on-idle=false
lock-after=false

[1]
item-type=0
display-name=key2
secret=pass2
mtime=1311900380
ctime=0

Edit the files using your favorite text editor. Make sure to change the section numbers so they are consecutive and do not overlap.

$ cat foo.keyring 

[keyring]
display-name=foo
ctime=0
mtime=0
lock-on-idle=false
lock-after=false

[1]
item-type=0
display-name=key1
secret=pass1
mtime=1311897928
ctime=0

[2]
item-type=0
display-name=key2
secret=pass2
mtime=1311900380
ctime=0

Back to the graphical keyring manager. Lock, then unlock the keyring so the changes take effect (right click > lock, right click > unlock). Alternatively you can close and reopen the keyring manager. You should now see all the keys you moved in one keyring.

two keyrings with keys moved

You can now set a password and the keyring files will once again be encrypted.

Tags:

Login

Keyrings