Technology and troubleshooting.

Monday, October 2, 2017

A Free and Simple Network Device Configuration Change Management Solution in CLI using puTTY.

Have you had trouble tracking changes to devices in you infrastructure.?
Do you not have budget to spend a pretty penny on log management software

I faced the same issue some time ago and it had me thinking.
What is the best way to keep track of the changes made while also reducing the effort it takes to document, validate and rollback the changes if necessary, without having to spend on costly and/or complicated software.

Without further ado, let us get to the crux of the solution by explaining how it works first and then giving you the method i used to implement it.
A Free and Simple Network Device Configuration Change Management Solution in CLI using puTTY.

There maybe better ways to go about this. If you have any, please highlight it in the comments below.

_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

The Command Line Interface is most often used to make configuration changes to network devices and Linux systems with the help of a terminal emulator using SSH or Telnet.

We make use of one of the most famous terminal emulator puTTY.

Putty is a small but versatile emulator with a wide variety of features and functions.

The feature we would be using would be the session logging feature.

What we do is, create a custom profile in putty with a predestined location and save a time-stamped log file to that location every time putty is invoked.

It would be best to have the latest version of puTTY for this to work, but it may work in earlier versions as well.

-----------------

I went about accomplishing this in a windows system by tweaking the registry settings for putty, under [HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\

Under that create a new custom profile that stores the log files in a centralized location. This is invoked every time putty is opened with a batch script.

Here's an example to the reg file and batch script, which you can modify and use according to your needs.

Modify and save the following as a .reg file.


--------------------------------------------------------------------------------------------------------
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\check]
"LogFileName"="\\\\<Share Location>\\Network Change Log\\&Y-&M-&D-&T.log"
"LogType"=dword:00000001

---------------------------------------------------------------------------------------------------------
I have saved it as Netmon.reg and I have named the custom puTTY profile as check.

I have written the script in such a way that the reg file is imported automatically, even if it is not present, in case the script is started in a new machine.

-----------------------------------------_________________________-----------------------------------
@ECHO off

net use L: /d
net use L: \\<Share Location>
reg query HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\check

if %ERRORLEVEL% EQU 1 goto INSTALL
REM if %ERRORLEVEL% is true reg is not installed.
start putty.exe -t -l "check" REM Starts a putty session with check profile loaded
pause...
EXIT /B

:INSTALL
pause...
xcopy "\\<Share>\Network Change Log\Setup\Netmon.reg" %TEMP% /Y REM copy the reg file to REM temp folder
reg import %TEMP%\Netmon.reg
pause...
start putty.exe -t -l "check"

---------------------------------------------_________________________--------------------------------------

We can also convert the above batch script to exe, using a simple batch script to exe converter and customize further to suit individual needs and requirements.

Hope this will be simple way for you to keep track of changes.


Share: