DEV Community

David Ngugi
David Ngugi

Posted on

Exporting seahorse keyring to keepassxc

If you are like me and started putting your passwords into the default keyring application on Linux, then you'd probably want to move them when you switch. The default Seahorse keyring application on Ubuntu doesn't have an export feature. Here are the steps to export out to keepassxc, a modern key manager.

You can download and install keepassxc from here -> https://keepassxc.org/download/#linux

Unlock your Seahorse keyring

  1. Right click on the keyring to export and select "Change password".

Image description

Enter the old password and then leave the new passwords empty and select "Continue". Accept any warnings shown.
Now your keyring is decrypted and looks like this:

crazywizard@crazywizard-ThinkPad-X1-Carbon-Gen-9:~/.local/share/keyrings$ cat login.keyring 
[keyring]
display-name=Login
ctime=1695477404
mtime=0
lock-on-idle=false
lock-after=false

[14]
item-type=0
display-name=Mysql@sqlreplica.example.com:3306
secret=mypassword
mtime=1543408141
ctime=1543408141

[14:attribute0]
name=account
type=string
value=crazywizard

[14:attribute1]
name=service
type=string
value=Mysql@sqlreplica.example.com:3306

[14:attribute2]
name=xdg:schema
type=string
Enter fullscreen mode Exit fullscreen mode

Transform/Export contents to csv format

  1. Copy the decrypted keyring to your /tmp directory. In Ubuntu 20.04+ , the keyring is located in the path ~/.local/share/keyrings
  2. Save this Python script and run it, specifying the keyring_file and csv_file to match yours.
import csv
import configparser

# Input and output file paths
keyring_file = "/tmp/login.keyring"  # Replace with your actual keyring file
csv_file = "keyring_export.csv"

# Parse the keyring file with interpolation disabled
config = configparser.ConfigParser(interpolation=None)
config.read(keyring_file)

# Prepare data for CSV
entries = []
for section in config.sections():
    if section.isdigit():  # Key entries are numeric
        display_name = config.get(section, "display-name", fallback="")
        secret = config.get(section, "secret", fallback="")
        username = ""
        service = ""

        # Extract attributes
        for key in config:
            if key.startswith(f"{section}:"):
                attr_name = config.get(key, "name", fallback="")
                attr_value = config.get(key, "value", fallback="")
                if attr_name == "account":
                    username = attr_value
                elif attr_name == "service":
                    service = attr_value

        # Add to the entries list
        entries.append(["Imported", display_name, username, secret, service, "Imported from Seahorse"])

# Write to CSV with proper columns
with open(csv_file, "w", newline="") as f:
    writer = csv.writer(f)
    writer.writerow(["Group", "Title", "Username", "Password", "URL", "Notes"])
    writer.writerows(entries)

print(f"Export complete! File saved as {csv_file}")

Enter fullscreen mode Exit fullscreen mode

Import to keepassxc

Next, import the generated csv file in keepassxc via Database->Import->CSV File. Follow the prompts including setting up a password for your database.

Image description

Success!! Your seahorse passwords are now imported on keepassxc.!

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs