Skip to content

tunnel - reload config#792

Open
commonism wants to merge 3 commits intoronf:developfrom
commonism:tunnel-reload-config
Open

tunnel - reload config#792
commonism wants to merge 3 commits intoronf:developfrom
commonism:tunnel-reload-config

Conversation

@commonism
Copy link

This change fixes an issue when having using alias for tunnel hosts.
The ssh configuration has to be reloaded for the tunnel (alias) to evaluate to the proper values (e.g. User)

I think the unit test needs some additional work, I was unable to assert on something due to lack of values.
It'd be great if it was possible to test the server for logins for this.

e.g.

assert sorted(server.logins) == sorted(["jumper","ckey"])

@ronf
Copy link
Owner

ronf commented Feb 7, 2026

Thanks for the report.

The "reload" keyword wasn't really meant to be used in a call to connect(). AsyncSSH should already be rereading the configuration file for each new connect() call, with updated host/port/username information each time. Reload is meant to be used when you have an already populated SSHClientConnectionOptions object and you need re-evaluate the config after updating one of the matchable inputs, like when doing hostname canonicalization.

Can you provide an example where it fails without this change? I tried connecting through multiple jump hosts where I changed the host, port, and username and it got the right values on each hop, even without this.

@commonism
Copy link
Author

You are correct.
I've updated the unit test using a dedicated jump host service - it works.
I'll keep this open, trying to reproduce.

Thanks

Port is not


INFO:asyncssh:Opening SSH connection to 127.0.0.3, port 22
@commonism
Copy link
Author

Now it reproduces.

Host jump
        HostName 127.0.0.3
        Port {jump_port}
        User jumper

Host target
        Hostname 127.0.0.2
        Port {self._server_port}

Match final host 127.0.0.2
        ProxyJump jump
   ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.3', 22)

And my fix does not.

Anyway - is there a way to run a single unit tests?
I struggle due to the relative imports in tests/ without a package ("ImportError: attempted relative import with no known parent package")

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.

2 participants