Skip to content

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

@kmccormick

Description

@kmccormick

At the bottom of my ~/.ssh/config, I have this section because my local username doesn't match my most common remote username:

Host *
User kmccormick

When running pytest, any paramiko host always uses the kmccormick user, even though I specify vagrant. It's the same whether it is set on the command line or in conftest.py with get_host, e.g.:

pytest --hosts "paramiko://vagrant@127.0.0.1:2222" 
get_host("paramiko://vagrant@127.0.0.1:2222")

This breaks the convention with ssh and ssh_config where earlier options override later options; command line options should override anything in ssh_config. It looks like it's had the same behavior since ~/.ssh/config was added as a fallback in 5c3388c4.

_load_ssh_config() should only set cfg["username"] = value if user isn't already set. That should probably also be extended out to other settings besides just username.

I'm working around this by supplying an ssh config file. Even /dev/null will do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue/PR relates to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions