I have a few routers and switches that were deployed to remote locations and the crypto key was not generated before they were shipped, they are working and I have SNMPv3 write access to them but I want to ssh to them without having to travel to site with console cable and laptop. Want to know snmpset oid to generate crypto key.
You can use the below to just send a list of commands to the router the file has the actual commands
config t crypto key generate rsa exit
Then ssh to the router and complete the config
or just enable telnet if you can get away with it
config t vty 0 4 transport input ssh telnet exit
I have a perl script that does this to reset enable passwords
The mib is
From the management station command line, with the use of the MIB object hostConfigSet, enter this:
% snmpset -t 60 172.16.99.22 \ private .22.214.171.124.126.96.36.199.188.8.131.52.191.135 \ s router-config
% snmpset -t 60 172.16.99.22 private \ enterprises.184.108.40.206.220.127.116.11 = "router-config"
I don't know if you can fix the SSH directly through SNMP. However, a lot of Cisco's suppport SNMP triggered config downloading or uploading from/to a TFTP server. You should be able to upload a new config containing the SSH stuff.
You need the CISCO-CONFIG-COPY-MIB, available on IOS >= 12.0. If you have the device config, you can create a new version including the SSH stuff and upload it. If not, first download the running config from the device.
Important note: uploading to the running config merges your upload into the existing config, but uploading to the startup config overwrites what's already there.
Cisco's instructions can be found here