Skip to content

Conversation

@bechampion
Copy link

@bechampion bechampion commented Nov 28, 2025

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
Copy link

DiegoDAF commented Dec 3, 2025

Yep, nice. Good catch.

@DiegoDAF
Copy link

DiegoDAF commented Dec 3, 2025

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
Copy link
Contributor

j-bennet commented Dec 5, 2025

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

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