Skip to content

Preserve explicit Paramiko username#817

Open
Herrtian wants to merge 2 commits into
pytest-dev:mainfrom
Herrtian:preserve-paramiko-explicit-user
Open

Preserve explicit Paramiko username#817
Herrtian wants to merge 2 commits into
pytest-dev:mainfrom
Herrtian:preserve-paramiko-explicit-user

Conversation

@Herrtian
Copy link
Copy Markdown

@Herrtian Herrtian commented May 1, 2026

Fixes #643.

When Paramiko loads ssh config defaults, a Host * user should not replace a username that was already supplied in the host spec, like paramiko://vagrant@127.0.0.1:2222.

This keeps the ssh config user fallback for host specs without a user, and adds a small regression test for both paths.

Checked with:

uv run --with paramiko python -
uv run --with ruff ruff check testinfra/backend/paramiko.py test/test_backends.py
uv run --with mypy --with types-paramiko --with paramiko --with pytest mypy testinfra/backend/paramiko.py

I also tried the focused pytest test on Windows, but this repo's test conftest hits Docker probing before collection and currently trips a Windows bytes-args issue in the local backend, so I verified the Paramiko config path directly instead.

@Herrtian Herrtian force-pushed the preserve-paramiko-explicit-user branch from c788cbc to e8c2f70 Compare May 1, 2026 15:19
@Herrtian
Copy link
Copy Markdown
Author

Herrtian commented May 4, 2026

Pushed 24ebb76 to fix the mypy failure from the now-unused type ignores. I checked tox -e mypy, tox -e lint, and git diff --check locally. The remaining py311 failure is in the existing Ansible encoding test, so I left that out of this Paramiko-focused change.

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.

Paramiko backend overwrites username with ~/.ssh/config defaults

1 participant