ronf / asyncssh

AsyncSSH is a Python package which provides an asynchronous client and server implementation of the SSHv2 protocol on top of the Python asyncio framework.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using ssh client config

4l1fe opened this issue · comments

commented

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?

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.

commented

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]

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.

commented

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

Ah, gotcha - sounds good!