Ssh – Passwordless entry via public key authentication to a HP 2626 switch


I am trying to get the output of some 'show' commands in linux and print them in a file
It's a HP 2626 switch
1. How can i setup Passwordless entry via public key authentication to the switch
2. How can i make a bash command to login to the server and then write the output of the switch in a file

*only ssh access is aplicable here

Best Answer

First of all, note that the RANCID tool can be used to automate the process of tracking your switch config over time. I haven't used it myself but the docs indicate it works with Procurve switches. I strongly recommend you investigate using it.

Aside from that, your first step is to enable ssh access to the switch and upload your public ssh key. Here's a great howto for doing that.

Once you have ssh access working for the manager or operator account on the device, you will need to use something like expect to automate ssh connections to the machine. This Stack Overflow posting has some great tips on how to do that.

But again, I strongly recommend you try to get RANCID working first, since that's a more standardized way to do this, and will scale better if you have more than one switch, or switches from different vendors.