Backing up HP switch configs.
Goal: Provide a central backup of all HP switch configs. The configs are downloaded and copied to a TFTP server via the SSH command line shell.
(ie: SSH into a switch and copy the running config down to a file on a TFTP server. Automatically. For a bunch of switches.) The script and tools here are used specifically with HP switches....but...with a little effort, they could probably work with just about any manufacturer.
Requires:
tftpd32.exe http://philippe.jounin.pagesperso-orange.fr/tftpd32_download.html
kitty.exe https://www.fosshub.com/KiTTY.html https://github.com/cyd01/KiTTY
tftpd32.exe is a free, open-source TFTP server that also includes a variety of different services
kitty.exe is a fork of PuTTY
(if you don't know what Putty is, or what TFTP is, you might want to bail at this point.)
Issues / Problems:
1. Older HP switches may not have the SSH option available.
Goal: Provide a central backup of all HP switch configs. The configs are downloaded and copied to a TFTP server via the SSH command line shell.
(ie: SSH into a switch and copy the running config down to a file on a TFTP server. Automatically. For a bunch of switches.) The script and tools here are used specifically with HP switches....but...with a little effort, they could probably work with just about any manufacturer.
Requires:
tftpd32.exe http://philippe.jounin.pagesperso-orange.fr/tftpd32_download.html
kitty.exe https://www.fosshub.com/KiTTY.html https://github.com/cyd01/KiTTY
tftpd32.exe is a free, open-source TFTP server that also includes a variety of different services
kitty.exe is a fork of PuTTY
(if you don't know what Putty is, or what TFTP is, you might want to bail at this point.)
Issues / Problems:
1. Older HP switches may not have the SSH option available.
Check the validity end date.... If you have an old switch, you *may* not be able to create a self signed cert. No cert....no ssh, unless you wan to create and import key pairs and such, and if you're doing that....then you probably don't need to be reading this.
2. Some HP switches require a key press to get to a login prompt...some don't (from a telnet / ssh session that is)
How the script works:
1. Gets the local machines IP address
2. Set up the tftpd32.ini file with the local IP
3. Checks to see if the tftpd server is already running. If not... launches tftpd32.exe
4. Gets a list of switches (hard coded)
5. For each switch in the list, it creates a "command1" and "command2" file
6. the command1 and command2 files are used by kitty to push keystrokes out to the switches*.
7. Login to the switch and copy the current running config to the TFTP server**
8. repeat for every switch
9. Zip all the configs up into a single zip.
* why 2 files ?? .. some HP switches have a "press any key to continue" home screen, and some take you directly to the login.
so first we just try to login using kitty and the "command1" file. If that doesn't work, we launch kitty again usinfg the "command2" file.
One of the two command files will work, the other will cause an error...we just keep rolling on errors.
** in my instance, I'm using telnet, not SSH, but...it's quite easy to convert the script to use SSH.
When it's all said and done....you should have a zip file, that contains all of the switch configs.
Copy the above script (after you make the necessary changes) to the same directory as Kitty and tftpd32 and run it...
The structure should look like this.....(above)
To use SSH (for the more security minded ) change the two kitty lines to:
FROM : & $CurrentDir\kitty.exe -telnet $switch -cmd command1
TO: & $CurrentDir\kitty.exe -ssh $switch -cmd command1
FROM: & $CurrentDir\kitty.exe -telnet $switch -cmd command2
TO: & $CurrentDir\kitty.exe -ssh $switch -cmd command2
To use SSH (for the more security minded ) change the two kitty lines to:
FROM : & $CurrentDir\kitty.exe -telnet $switch -cmd command1
TO: & $CurrentDir\kitty.exe -ssh $switch -cmd command1
FROM: & $CurrentDir\kitty.exe -telnet $switch -cmd command2
TO: & $CurrentDir\kitty.exe -ssh $switch -cmd command2
And that's it..... a little script, a little work, and a little knowledge....and all your switch configs are backed up to a nice little zip file.