Sunday, January 21, 2018

WSL as an alternative to Putty


Recent developments in the windows subsystem for linux have finally made this windows 10 feature a viable option to replace putty.

When I first started learning the ins and outs of Information Technology, I spent the majority of my time jumping between OSX and a variety of linux distros.  I picked up a cheap second hand Thinkpad T420 from my then employer for some Windows 7 based course work. I adapted to the machine relatively quickly, but found tasks that were trivial on a unix based OS always required third party apps and additional configuration just to get off the ground. 

My current employer is a windows only shop. Finding ways to adapt to and improve Windows 10 for my workflow has also been an interesting challenge, one I've really enjoyed so far. (I especially love using the virtual desktop feature.) I was however still bothered by the lack of native SSH, that is until I got my hands on a windows 10 machine that supported WSL. The Windows subsystem for linux presented an opportunity to both learn about WSL itself, sharpen my rather rusty linux skills, and also provide a built in putty alternative.  


Prerequisites:
Windows 10 OS running at least Insider Build #16176


Installation: 
To install WSL, open a powershell prompt with administrative privileges and run 

   
Additional info can be found by following the link below
https://docs.microsoft.com/en-us/windows/wsl/install-win10


Connect via console cable: 
in powershell, use

    Get-wmiobject Win32_SerialPort | select-object name
           or
     chgport

To find which COM port your adapter is using.
I occasionally run into issues with some RS232 adapters that do not show as a serial port when        you run the first option above. They will however appear if you enter a chgport






You can call this directly from WSL by running powershell.exe, then your command


Using script to automatically track config changes: 
In WSL, the path to your C drive is /mnt/c
from their you can create a directory where you would like your transcripts written to.

I normally create an additional directory called workspace in which I store change transcripts and build notes.
"/mnt/c/Users/'myusername'/workspace/switchTranscripts/"

Save as a persistent alias in ./bash_aliases. I have mine saved as alias cya='python ~/cya.py'. Before any major changes I will run the script, enter a descriptive title, then follow up with a 'term len 0' and 'more system:running-config'. Giving me a full backup as well as a ledger of any changes made.



Ending your session 
When your ready to end your session, Enter '~.' to disconnect.
 More info can be found in the man page on the cu utility.




Killing session 
If you have a hung session, or you receive the message below,

You can rerun the chmod command above to take control of that COM port





Using Powershell to prep for a DHCP cutover

 Alright, here is the background.  Recently I was working on migrating a few locations off of bog standard Microsoft Windows DHCP server to ...