Skip to content
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

Using ssh client config #108

Closed
4l1fe opened this issue Sep 24, 2017 · 5 comments
Closed

Using ssh client config #108

4l1fe opened this issue Sep 24, 2017 · 5 comments

Comments

@4l1fe
Copy link

4l1fe commented Sep 24, 2017

Is there a way to use ~/.ssh/config where are a lot of settings in asyncssh.connect('just_name_of_settings') ?

I don't see such possibility in source. So do you have a plan to implement such feature?

@ronf
Copy link
Owner

ronf commented Sep 24, 2017

No, sorry, there's no way to support an OpenSSH-format "config" file right now. The problem is that there are a really large number of configuration settings supported by OpenSSH which there are no direct equivalents of in AsyncSSH, and so even if I had code which could parse that file, I wouldn't be able to apply many of the settings. Applying some settings and ignoring others seems like it could cause problems in many cases, so I don't plan on supporting that. AsyncSSH requires you to provide all these settings in the form of arguments to it directly in Python.

There is support for other file formats such as authorized_keys and known_hosts, as well as the key files themselves, but in all of those cases AsyncSSH is able to fully understand the contents of these files.

@4l1fe
Copy link
Author

4l1fe commented Sep 25, 2017

Thx for explanation.

It isn't a problem to write config parsing myself actually..
I've written it in such way:

for line in file.readlines():
    if line.startswith('HostName'):
        host = line.split()[1]
    elif line.startswith('User'):
        user = line.split()[1]

@4l1fe 4l1fe closed this as completed Sep 25, 2017
@ronf
Copy link
Owner

ronf commented Sep 26, 2017

If you have a very simple config file without any "Host" or "Match" lines, parsing like the above might work, but to properly parse all of the options in an SSH config file is a lot more involved than what you show here. Take a look at the ssh_config(5) man page for more details.

Even if I were to add support for Host and Match sections, though, there are nearly 100 directives which are supported by OpenSSH, and while many of the things they control are also features available in AsyncSSH, there would not be a one-to-one mapping of all of these configuration settings. More importantly, there are a number of OpenSSH directives which really have no direct counterpart in AsyncSSH at all such as BatchMode, the various Canonicalize options on hostnames, CompressionLevel, and the various Control options for setting up a "master" SSH process to multiplex through, to name just a few.

@4l1fe
Copy link
Author

4l1fe commented Sep 26, 2017

No no, i meant that i can do it myself =) i didn't write it like "look it is easy, make it pls"

@ronf
Copy link
Owner

ronf commented Sep 26, 2017

Ah, gotcha - sounds good!

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

No branches or pull requests

2 participants