How to add new Host to know_hosts with asyncssh

64 views
Skip to first unread message

Maharshi dave

unread,
Jun 15, 2020, 1:14:15 PM6/15/20
to asyncssh-users
Hi everyone, 

currently struggling to add a host from asyncssh. (currently using Windows Server 2016)

Thanks and regards,
Maharshi

Ron Frederick

unread,
Jun 15, 2020, 9:06:09 PM6/15/20
to Maharshi dave, asyncssh-users
Hello,


On Jun 15, 2020, at 10:14 AM, Maharshi dave <davema...@gmail.com> wrote:
Hi everyone, 

currently struggling to add a host from asyncssh. (currently using Windows Server 2016)

While AsyncSSH supports use of various files in the user’s .ssh directory, including .ssh/known_hosts, it only ever reads these files. It does not have any capability to write to these files itself. However, it does support you adding callbacks to do your own host key validation, where it will pass you either a host key or a host CA key and let you decide if it should be accepted or not. If you wanted to, you could then write your own code to update the “known_hosts” file
with this host or CA key. Just remember to be careful to do some form of file locking if you want to support multiple client connections being opened in parallel or if you have other SSH clients (such as OpenSSH) which might be also trying to modify this file. I haven’t actually looked at how OpenSSH handles that.

More discussion of this can be found at https://github.com/ronf/asyncssh/issues/237.

If you know the hosts you are going to be connecting to and their key isn’t changing, the simplest thing to do is to log in manually to the hosts using OpenSSH and let it add the host keys to .ssh/known_hosts. Once they are in place, AsyncSSH will use those keys.
-- 
Ron Frederick
ro...@timeheart.net



Reply all
Reply to author
Forward
0 new messages