-
Notifications
You must be signed in to change notification settings - Fork 16
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
asyncssh API change breaks parsing of config #54
Comments
@ronf can we by chance make these new arguments into |
If you want to preload some configuration options, the preferred approach is to use "options" rather than "config". If you do use config, the only supported mechanism is to pass in a list of path names of config files to load (which is handled as part of setting "options"). If I were to make these keyword args with default values, the new functionality of "match canonical" and "match final" would be broken as a result of not setting these values correctly. Calls to this "load" function really need to be coming from Do you know why sshfs felt the need for this wrapper? How is it used? |
thanks, @ronf
can you point me to the class / code please?
I think it's an utility function that was needed for DVC (to preload some config indeed) https://github.com/iterative/dvc-ssh/blob/main/dvc_ssh/__init__.py#L44 |
From what I can see, that Generally speaking, the expectation is that you'll pass AsyncSSH a I think it would be possible to take the existing keyword args in the DVC code and convert those to AsyncSSH "options" arguments (see the SSHClientConnectionOptions class), and allow one of those arguments for the user config to be passed in as a In OpenSSH 2.15.0 and later, there's a class method called You could also convert the keyword args to a new dictionary of AsyncSSH keyword args and just pass those in as keyword args to |
Conclusion:
|
I have provided the PR. Haha, test case is to be updated. The string is returned for config.get("ProxyCommand") but is compared against a list by using split(). After this I think it should work, :) |
I strongly recommend against pinning a specific version of AsyncSSH here. That would mean that anyone using this package would not be able to pick up any security vulnerability fixes, or other bug fixes. |
@ronf thanks for the detailed response. I also don't see an immediate need (see some questions / caveats below) to DVC to try to build an effective config itself. The logic seems to go back many years ago to this ticket: and this PR: It was using back then Now, we might not need all of this. A few caveats that I can immediately see:
login_info["username"] = (
config.get("user")
or config.get("username")
or user_ssh_config.get("User")
or getpass.getuser()
) will
if config.get("keyfile"):
raw_keys.append(config.get("keyfile"))
elif user_ssh_config.get("IdentityFile"):
raw_keys.extend(user_ssh_config.get("IdentityFile")) Can we pass an additional key file to @ronf if you have quick suggestions / thoughts on these items ^^ I would appreciate any help. |
Starting with the easiest, the username is gotten from one of the following (in order of precedence):
Really, there's a value As for ProxyCommand, it shouldn't need to be special-cased. It can come from keyword args, options, or config, with a similar precedence to the above, but with the default being unset. I'm guessing the "login_info" you show here is related to trying to convert from SSH config values to Paramiko values you mentioned above. As for showing user/host/port, there are really two different sets of values here. There's the requested user, host, and port and there's the rewritten version of those after parsing config files, if you decide to support those. If your application passes values to connect() via keyword arguments or options, that will take precedence over any config files, which may or may not be what you want. As for keys, you can have multiple IdentityFile lines in a config file that can be conditionally matched, building up a set of keys to load for all the config lines which match. If you specify keys via keyword arguments or options, though, you have to specify the complete list (doing any conditional logic yourself to build that list). Note that you can load multiple config files. However, there isn't an easy way right now to state that you want to load the system default config if it exists and then some config file of your own (or vice-versa in the ordering). You'd have to check yourself to see if the system config file existed and then specify the complete list of files to load, being careful to pick the order, as most config settings will lock on the first config rule which matches, ignoring later lines that match. IdentityFile is an exception in that regard. |
The v2.19.0 release of
asyncssh
has added support for hostname canonicalization. With this change, two new arguments were added toSSHClientConfig.load
:canonical
andfinal
. We should also pass these parameters insshfs
, because right now thelocal_user
anduser
are passed in their places, which breaks parsing the config inconfig.py
:sshfs/sshfs/config.py
Lines 23 to 31 in 34b52b2
https://github.com/ronf/asyncssh/blob/95756fa4eb54826adb9156b87443d945fd1ed4f8/asyncssh/config.py#L428-L430
The text was updated successfully, but these errors were encountered: