10-19-2020 04:53 AM
I know how to do fetch of ssh host keys for a device from NSO CLI or using RESTCONF API.
Is it possible to do fetch of ssh host keys from within the python part of a service, i.e. in the myService/python/myService/main.py?
Looking at this one: https://community.cisco.com/t5/nso-developer-hub-discussions/ssh-fetch-host-keys-is-this-function-code-visible/td-p/3425348
But was still unable to figure out how to do it.
Thanks
Solved! Go to Solution.
10-19-2020 05:57 AM
You typically do not want to have any device interactions during the critical part of a transaction. Best is to capture the error in the northbound system and do a separate API call to request the keys.
10-19-2020 05:32 AM - edited 10-19-2020 05:32 AM
Hi bfinnema,
You can fetch the value as follows
dev = root.devices.device['ios-dev0'] list(dev.ssh.host_key)[0].show_fingerprint().value
Thanks,
Kiran Kumar
10-19-2020 05:57 AM
You typically do not want to have any device interactions during the critical part of a transaction. Best is to capture the error in the northbound system and do a separate API call to request the keys.
10-19-2020 06:06 AM
Hi Kiran,
Thank you for the response. This assumes that I have already fetched the host keys and just want to view them. Because I have not done that, I get "IndexError: list index out of range".
What I want to do is fetch the host keys from the device. I have this status of the device:
admin@ncs# devices device asr9001 check-sync result error info Failed to authenticate towards device asr9001: Unknown SSH host key
I know I can fetch host keys using CLI like this:
admin@ncs(config)# devices device asr9001 ssh fetch-host-keys
But I want to do it within the python part of a service. How can I do that?
Kind Regards
/Bo
10-19-2020 10:26 PM
It's straight fwd, and I have update the output possibility in the above link which u shared.
dev = root.devices.device['asr9001'] output = dev.ssh.fetch_host_keys() # I have pasted the yang for output possibility in the link u shared # based on output you can take steps accordingly
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide