-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Postpone ssh config parsing file when connecting to device for doing … #812
base: develop
Are you sure you want to change the base?
Conversation
…token substitution at that time Signed-off-by: Florian LACOMMARE <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the contribution! I left a comment which should be addressed before merging:
@@ -573,7 +568,8 @@ async def _init_jump_host_connection( | |||
) | |||
self._tunnel = await asyncssh.connect( | |||
self.jump_host, port=self.jump_port, | |||
options=jump_host_options, username=self.jump_user) | |||
options=jump_host_options, username=self.jump_user, | |||
config=[self.ssh_config_file]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work if no ssh config file is provided as we would pass a list containing None to the connect()
function, causing it to fail.
I suggest to directly provide the string and, if empty or None, an empty tuple (as according to the docs explicitly passing None
, asyncssh won't get the default configuration in .ssh/config
).
config=[self.ssh_config_file]) | |
config=self.ssh_config_file or ()) |
@@ -729,7 +720,8 @@ async def _ssh_connect(self): | |||
self.address, | |||
username=self.username, | |||
port=self.port, | |||
options=options) | |||
options=options, | |||
config=[self.ssh_config_file]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the comment before:
config=[self.ssh_config_file]) | |
config=self.ssh_config_file or ()) |
Is this something still useful? |
Not sure, no one's ever asked for this but this user, and since the method he was pursuing was not a scalable answer, and he didn't address the comments, we haven't merged it |
Related Issue
Fixes ronf/asyncssh#520
Description
When using variables in ssh config file like
%h
or%p
,asyncssh
is doing token substitution with host address and port. But sincesuzieq
is creating anasyncssh
options before trying to connect to device,asyncssh
is not aware about host and port info.Type of change
New Behavior
The goal is to postpone ssh config file parsing at the
asyncssh.connect()
time, where host and port is known.There is another way, explained in the comments section.
...
Contrast to Current Behavior
Actually, when building the options, substitution look like this :
nc -X 5 -x 127.0.0.1:2226 '' 22
Instead of
nc -X 5 -x 127.0.0.1:2226 X.X.X.X 22
...
Discussion: Benefits and Drawbacks
It's very usefull for supporting multiplexing ssh session with OpenSSH options without adding such feature to
suzieq
...
Proposed Release Note Entry
asyncssh
OpenSSH token substitution (%h, %p) by postponing parsing ssh config file....
Comments
There's two way to fix this issue, the other way is to provide
host
andport
information toasyncssh
when building ssh options. I tested both and it works, but I prefer the way to postpone config parsing in theasyncssh.connect()
call instead of doing parsing before and pass the result toasyncssh.connect()
.Second way like this :
Example of ssh config file :
Double Check
develop
branch.develop
branch.--signoff
applied