-
Notifications
You must be signed in to change notification settings - Fork 69
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
Add additional key type flags to hostcheck module - update example #52
Comments
Hello, |
@JoelStienlet Thanks for the info, I tried but I am getting the same result regardless of the encoding of the hostname:
I of course made sure that the host is in the known_hosts file so it should find it no problem.
Sure it does not complain but the code still does not quite work... going to spend quite some more time on this trying to work out what is wrong as I am not very familiar with the underlying library its hard to debug this one |
Can you check the value of type_mask? I've used LIBSSH2_KNOWNHOST_TYPE_PLAIN: |
Hi there, Thanks for the interest and report. The example script is correct. The reason it does not work for the above is because the key type in the hosts file is Python version does not matter, though the host parameter must be in bytes - The exception is because a matching host and key type cannot be found - there can be multiple keys per host of different types. On type check errors where a host does match the error returned is There is now ECDSA and ED25519 key type support in libssh2, neither of which have flags exposed in PRs welcome for both of these. |
Flags updated for latest libssh2. Examples welcome. |
Using Python 3.6 the example host key verification code generates the following error message:
Traceback (most recent call last):
File "example_host_key_verification.py", line 29, in
else LIBSSH2_KNOWNHOST_KEY_SSHDSS
NameError: name 'LIBSSH2_KNOWNHOST_KEY_SSHDSS' is not defined
Easily fixed by adding LIBSSH2_KNOWNHOST_KEY_SSHDSS to the imports but even then it will still not work:
Traceback (most recent call last):
File "example_host_key_verification.py", line 39, in
kh.checkp(host, 22, host_key, type_mask)
TypeError: Argument 'host' has incorrect type (expected bytes, got str)
Now I am not sure what exactly it wants here, converting the host string to bytes is not the answer feeding it the IP that the host resolved as in bytes does not seem to work either.
Using python 2.7 instead (bad, bad, bad, time to migrate already)
Traceback (most recent call last):
File "example_host_key_verification.py", line 39, in
kh.checkp(host, 22, host_key, type_mask)
File "ssh2/knownhost.pyx", line 252, in ssh2.knownhost.KnownHost.checkp
ssh2.exceptions.KnownHostCheckNotFoundError: ('Host %s not found in known hosts collection', 'localhost')
Yet I am 100% certain that localhost is in the known hosts file so I have a feeling that even though there is no complaint about not getting bytes as a first parameter to kh.checkp on line 39 it is not able to deal with the string it gets and check the host/fingerprint correctly against the known hosts file.
The text was updated successfully, but these errors were encountered: