Skip to content

Adding port so keyring is not overwritten#1536

Open
bechampion wants to merge 2 commits into
dbcli:mainfrom
bechampion:main
Open

Adding port so keyring is not overwritten#1536
bechampion wants to merge 2 commits into
dbcli:mainfrom
bechampion:main

Conversation

@bechampion

@bechampion bechampion commented Nov 28, 2025

Copy link
Copy Markdown

Description

Keys in keychain are overwritten when same user/host is used (this happens a lot when you proxy over ssh where the host is always localhost and username pretty much is always the same)

Before change

image

After change

image

Checklist

  • I've added this contribution to the changelog.rst.
  • I've added my name to the AUTHORS file (or it's already there).
  • I installed pre-commit hooks (pip install pre-commit && pre-commit install).
  • Please squash merge this pull request (uncheck if you'd like us to merge as multiple commits)

@DiegoDAF

DiegoDAF commented Dec 3, 2025

Copy link
Copy Markdown
Contributor

Yep, nice. Good catch.

@DiegoDAF

DiegoDAF commented Dec 3, 2025

Copy link
Copy Markdown
Contributor

Thinking again, I could recommend user@host:port to be more like in ssh (or even pgpass format with colon)

And, maybe, or not, a "legacy" idea to try with the old format.

key_with_port = f"{user}@{host}:{port}"
passwd = auth.keyring_get_password(key_with_port)

if not passwd:
    key_legacy = f"{user}@{host}"
    passwd = auth.keyring_get_password(key_legacy)

# and ofc, save it in the new type with port
if passwd:
        auth.keyring_set_password(key_with_port, passwd)

@j-bennet

j-bennet commented Dec 5, 2025

Copy link
Copy Markdown
Contributor

@DiegoDAF I think it's ok to not try for backwards compatibility in this case.

@DiegoDAF

DiegoDAF commented Dec 5, 2025

Copy link
Copy Markdown
Contributor

yep, it's not necessary to keep the compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants