So I am trying to build an application that logins to remote routers via SSH and run some commands and fetch the output.
I am using JSCH 0.1.55 version of the JAR. But I ran into a real hurdle with the StrictHostChecking. Now whatever I have Googled here, setting it to no
is a security risk, but I am able to connect to the routers just fine with it. But setting it to a yes
is where I am facing some issues.
com.jcraft.jsch.JSchException: reject HostKey: XXX.XXX.XXX.XXX
That is what I get. But to be honest, there are so few good code examples of a proper way of using it, I am at a dead end.
I can set the key for one router in my known_host file for sure, but how do I make the code work when there are 100s of new router out there on the field and new ones being added all the time and still make it secure?
Any pointers on this would really appreciated.