Skip to content

Passing username as SSHClientConnectionOptions attribute does not work, local username is used instead #803

@cdleonard

Description

@cdleonard

Sample pseudocode:

def test(myhost: str, myuser: str):
    options = SSHClientConnectionOptions()
    options.username = myuser
    async with asyncssh.connect(
        host=host,
        options=options,
    ) as conn:
        result = await conn.run("whoami", check=True)
        assert isinstance(result.stdout, str)
        assert result.stdout.strip() == myuser

The username passed in SSHClientConnectionOptions is ignored, local username is used instead. Works as expected if username is passed into asyncssh.connect kwargs instead.

Can be trivially reproduced without a target, this sample fails:

async def test_options_construct_ignores_username():
    options = SSHClientConnectionOptions()
    options.username = "user"
    new_options = await SSHClientConnectionOptions.construct(options)
    assert new_options.username == "user"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions