Python: Installing netmiko (paramiko) on Windows 10 PC for automation

In order to write a script and automate your infra devices via ssh/telnet, python uses paramiko. In Linux/MAC OS environment, it is easy to install or this module is already included as a package. For windows, the module installation process is more cumbersome. I have come a few articles on Google attempting to do this but the examples given¬†were clear as mud. Here is a precise steps for the installation and also some troubleshooting URLs referenced for your convenience. ūüôā

1. Install Python (https://www.python.org/downloads/https://www.python.org/downloads/)

2. Install Anaconda. (https://store.continuum.io/cshop/anaconda/https://store.continuum.io/cshop/anaconda/)

3. From the Anaconda Prompt (Shell), run “conda install paramiko”.

4. From the Anaconda Prompt (Shell), run “pip install scp”.

5. Install git for Windows. (https://www.git-scm.com/downloadshttps://www.git-scm.com/downloads)

6. From Git Bash window. Clone netmiko with “git clone https://github.com/ktbyers/netmiko”

7.From Git Bash window. Unable to install Netmiko in windows after it cloned. define the path for python.

bchoi@AUD-4D1KYF2 MINGW32 /h/netmiko (develop)

$ export PATH=$PATH:/C/Users/bchoi/AppData/Local/Programs/Python/Python36-32

8. cd into the netmiko directory and run “python setup.py install”.

bchoi@AUD-4D1KYF2 MINGW32 /h/netmiko (develop)

$ python setup.py install

End result: You can now use parmiko on your windows PC!

paramiko OK

Tip1: To display Windows 10 Roaming folder

https://answers.microsoft.com/en-us/insider/forum/insider_wintp-insider_files-insiderplat_pc/windows-10-roaming-folder/6c99ffdc-90d5-4d1d-8ab1-b4f448ecc8ee?auth=1https://answers.microsoft.com/en-us/insider/forum/insider_wintp-insider_files-insiderplat_pc/windows-10-roaming-folder/6c99ffdc-90d5-4d1d-8ab1-b4f448ecc8ee?auth=1

Unable to install Netmiko in windows after it cloned:

https://stackoverflow.com/questions/47726184/unable-to-install-netmiko-in-windows-after-it-clonedhttps://stackoverflow.com/questions/47726184/unable-to-install-netmiko-in-windows-after-it-cloned

 

Advertisements

VB Operators, Expressions and Statements

This is sourced straight from the famous Visual Basic videos of Bob Tabor at Channel 9. The video #07 VB Operators, Expressions and Statements. Writing this down so this becomes my note and a reference point. Thanks for great training videos on Channel 9, Bob! You are like my long lost Uncle Bob!

Statements are like a full sentence, consist of expression
Expressions made of operators and operands, like nouns in a sentence.
Memorize some basic operators so you can do something with the operands.

 

‘ Assignment operator
x = 3

‘ Addition operator
x = 3 + 4

‘ Subtraction¬†operator
x = 4 – 3

‘ Multiplication operator
x = 10 * 5

‘ Division operator
x = 10 / 5

‘ Equality operator
If x = y Then
‘ Stuff goes here
End If

‘ Greater than operator
If x > y Then
‘ Stuff goes here
End If

‘ Less than operator
If x < y Then
‘ Stuff goes here
End If

‘ Greater or equal to operator
If x >= y Then
‘ Stuff goes here
End If

‘ Less or equal to operator
If x <= y Then
‘ Stuff goes here
End If

‘ Condition OR operator
If x > y Or a > b Then
‘ Stuff goes here
End If

‘ Condition and operator
If x > y And a > b Then
‘ Stuff goes here
End If

‘ Member access and Method invocation
Console.WriteLine(“Hi!”)

 

Source: https://channel9.msdn.com/Series/Visual-Basic-Development-for-Absolute-Beginners/Operators-Expressions-and-Statements-07

 

CCNA Data Center 640-911 DCICN ‚Äď Note 18, IPv6 Introduction

This is my first blog in 2016, I have been on holiday mode as I have been on one the longest annual leave in my life. Hope you understand the family commitment when you and your kids are on summer holiday (here in Sydney, Dec/Jan/Feb is blazing summer).

 

IPv6, the history and does it really matter to you or anyone?

The simple answer is YES, then why? The single biggest driver behind the development and introduction of IPv6 is  a long prediction of lack of usable IPv4 IP addresses since the explosion of World Wide Web (www) in 1995. The www development goes back to 1991 and then the introduction of grandfather web browser, Mosaic was first introduced in 1993. By year 1995, one third of IPv4 addresses were consumed, by year 2000, half of all IPv4 addresses were use.

As reviewed in previous notes, IPv4 consists of 32 bit address structure and theoretically that should give us 2 to the power of 32 IP addresses, that is¬†4294967296 IP addresses or roughly, 4.3 billion IP addresses . But not all IP addresses are usable such as the reserved IP addresses for private network use as well as the Class E addresses reserved for development and testing purposes. In other words, only around 2.5 billion IP addresses are true usable addresses. If you just check out our world’s population today ( http://www.worldometers.info/world-population/, China = 1.407 billion and India =¬†1.2912 billion people,), just looking at top two countries’ population figures, you can feel the IPv4 address shortage on your skin. The trend is that the world’s network has been doubling in size every year for the past 15 years. (https://en.wikipedia.org/wiki/IPv4_address_exhaustion)

With the advancement of new technologies comes the rapid deletion of available IPv4 IP addresses. Anything that’s related to mobile communications and entertainment as well as all other areas seems to be needing more and more IP addresses for everyday use. In the past, it was expected that all the IPv4 addresses would be depleted by 2011 but it is 2016 and we are still using IPv4 address without much thought, all thanks to the counter measures put into place to slow down the IPv4 IP address deletion. e.g.) The fine art of sub-netting, a practical use of DHCP and IP Natting.

 

 Quick note on history of IPv6:

1990 – IETF had predicted that all class B IPv4 IP addresses will be deleted by 1994
1991 Nov РIETF formed  ROAD (ROuting and ADress) Group in Santa Fe, US.
1995 – IPNG (IP Next Generation) Workgroup had written and submitted ‘RFC 1883’, this RFC has become the foundation of current IPv6.
1996 – 6Bone was introduced. 6Bone was a test-bed for IPv6 vulnerabilities connecting 57 countries across 1100 sites.
1999 – IPv6 Forum was launched to standardize the use of IPv6
2006 Jul 06 – 6Bone was decommissioned after 10 years of testing.
Current – Majority of IP products are manufactured with IPv6 capabilities and compatibility. IPv6 is slowly phasing out IPv4 around the world.

Source: https://en.wikipedia.org/wiki/IPv6

 

Quick note on 10 Advantages (Characteristics) of IPv6:
1. Larger IP address space than IPv4, 32 bits based IPv4 vs 128 bits based IPv6
2. Better end-to-end connectivity than IPv4
– peer-to-peer application connections such as games, video conferencing, file sharing and VoIP
– No need to use NAT as the shortage of addresses is thing of IPv4
3. Plug-n-Play feature of IPv6
– plug-and-play auto-configuration, e.g.) DHCPv6
4. Simplified Header structures leading to faster routing
5. Better security features
– use of IPSec (a built-in feature)
6. Improved QoS features
7. Improved Multicast and Anycast abilities
8. Better mobility features
9. Ease of administration over IPv4
10. IPv6 follows the key design principles of IPv4

Source: http://www.ipv6.com/articles/general/Top-10-Features-that-make-IPv6-greater-than-IPv4.htm

In the next section, we will look at some characteristics of IPv6 and then in the final section of IPv6, I will demonstrate IPv6 in a simple lab. Happy blogging, reading and all the best with your learning and career in 2016.

Cisco APE’s TIP: Configuring a Cisco Router as an Authoritative NTP Server

Why NTP matters to your network?

It is all about time precision and all systems in your infrastructure running on the same time. Network Time Protocol (NTP) is a critical service for all IP devices. Servers and network devices need to synchronize with a reliable time source such as an NTP server.

 

Real life scenario:

Scenario: Client is using a Windows 2012 Server running Windows 32 Time Services (W32TM) as their only NTP server. Which is not a full NTP deployment and Cisco devices have been pointed to this server, but Cisco IOS devices cannot synchronize time with Windows NTP server. Cisco recommends Linux or IOS based devices to provide this NTP services to other devices. This is a real life scenarios based on my client’s network.

 

 

Pre-task: Synchronize hardware clock to software clock

Why? Most of Cisco routers have two clocks, one, a battery-powered hardware clock, a.k.a ‘calendar clock’ and a software clock, a.k.a ‘(software) clock’ in the IOS CLI.

 

Step 1: Check the software clock:

R1#show clock

12:57:03.186 AEDST Fri Dec 11 2015

 

R1#show calendar

12:44:30 AEDST Fri Dec 11 2015

 

As you can see, there is more than 12 minute time drift between the software and hardware clocks.

 

 

Step 2: Now synchronize the hardware time to the software time.

R1#conf t

R1(confg)#ntp update-calendar

 

Step 3: Now check the time synchronization:

R1#show clock

12:59:31.88 AEDST Fri Dec 11 2015

R1#show calendar

12:59:31 AEDST Fri Dec 11 2015

 

Excellent! Now both software and hardware clocks showing the same time. You are ready to configure your IOS as NTP server.

Note: if you don’t use ‘ntp update-calendar’, NTP services on the router will still work, but it will use the software clock time, so ‘show clock’ time.

 

 

Task: Configure your router (R1) as an Authoritative NTP Server

 

Step 1: Check NTP source interface

R1# show run | begin interface Loopback0

interface Loopback0

ip address 10.10.10.1 255.255.255.255

 

 

Step 2: Actual configuration to make the router an NTP server

R1# conf t

R1(confg)#ntp master 2           <<<I am leaving stratum 1 for atomic clock, it will use its internal IP as its source of time, so 127.127.1.1 will become stratum 1, its loopback0 will take stratum 2.

R1(confg)#ntp server loopback 0  <<<Use loopback0 as NTP server

R1(confg)#ntp source loopback0   <<<Use loopback0 as NTP source

 

Optional commands:

R1(config)#(clock timezone (any name) (timezone)

 

 

Step 3: Using R1’s time on another device (R2). Now synchronize R2’s time with R1’s time (NTP time).

R2# conf t

R2(confg)#ntp server 10.10.10.1¬† <<<10.10.10.1 is the IP of R1’s loopback0

 

Step 4: Wait for 1-5 mins and run show clock command for verification.

R1#show clock

13:09:30.77 AEDST Fri Dec 11 2015

R2#show clock

13:09:30.77 AEDST Fri Dec 11 2015

 

 

Useful commands:

show ntp status

show ntp association

Microsoft – File Checksum Integrity Verifier

Why run this tool?

Answer: Check the integrity of the file before apply to a system/servers/devices so you can avoid a big headache later

Step 1: Download the MD5 checksum program from Microsoft Site:

Step 2: Extract the file into your known folder

filechecksum1

Step 3: Run the tool in Command Line.

filechecksum2

E.G.) I am running a checksum of Cisco IP Phone firmware before an upgrade.

C:\Users\bchoi\Documents\fciv.exemd5 D:\Patch\cmterm-devicepack8.6.2.26159-3.cop.sgn
//
// File Checksum Integrity Verifier version 2.05.
//
f3aa5d2d5a12e1d57aeacdaa43ff1b4d d:\patch\cmterm-devicepack8.6.2.26159-3.cop.sgn

Step 4: Confirm the checksum value on the vendor’s download page and the value that you have received from the tool.

filechecksum3

Yo Gabba Gabba Cool Tricks 2: Capture all windows services on a text file before performing a major change on your Windows System

~ Begin your task ~

Step 1: Copy the following into notepad and give a name with file extension .vbs

strComputer = “.”

Set objWMIService = GetObject(“winmgmts:” _

& “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”)

Set colRunningServices = objWMIService.ExecQuery _

(“Select * from Win32_Service”)

For Each objService in colRunningServices

Wscript.Echo objService.DisplayName & VbTab & objService.State

Next

Step 2: I have given it a name of “listservices.vbs”. Also, to make my life easier, I have placed the file under C:\.

Step 3: Now open the command line with Administrator privileges

Step 4: First, move down to the location where you have saved your file, then run the visual basic script as below. I am saving the file in the same location with the name and date reference.

C:\>cscript listservices.vbs > c:\listservices17092015.txt

If you want to save this file in a specific location, you can create a folder and save it like this:

C:\>cscript listservices.vbs > c:\service list history\listservices17092015.txt

After you have run the script, a file will be saved with the file name given as below:

Now keep this copy of file for later use. When you open the file with Notepad++, it looks similar to below:

Step 5: Now perform your changes to the system, and compare the difference. In this example, I have manually stopped some services to demonstrate this in our example. I have given the file name “listservices17092015_after.txt”.

Step 6: Now open both files in Notepad++ and use ‘compare’ tool to pin point the stopped services. If this was a Windows Enterprise Server such as DHCP, AD, etc., one interrupted service will cause a big outage, now you know how to pin point the stopped or hanging service, you can restart it from windows services console. To easily get to Windows services console, go to Run >type in ‘services.msc’.

~ Task ended ~

Reference:

https://technet.microsoft.com/en-au/library/ee156587.aspx

https://notepad-plus-plus.org/

Yo Gabba Gabba Cool Tricks 1: Backup your data on failing OS (Windows/Linux)

One of my colleagues at work has asked me if I can help him to back-up/recovery some data (72.6Gb on 320GB HDD) from a laptop running Windows 7 which held¬†very important data for his cousin’s tax return documents. He has described the symptom as “The laptop will not boot up properly due to Windows boot-up file corruption or some sort, also the hard disk cannot be recognized when connected via Sata to USB coverter or Sata to motherboard as a second HDD. The HDD wasn’t completely dead and plates spindling.”

Unfortunately, the Hard disk was 320GB in size but was only partitioned into a single partition, so both OS and data resided on the same partition. I have tried my usual tricks on both Windows and Linux OS and the damn HDD cannot be detected hence, I was unable to back-up any data from this failed hard disk, then a little bit of googling pointed me to this URL: http://www.sevenforums.com/tutorials/256518-peppermint-live-cd-dvd-usb-create-emergency-backup.html. Wow! what a cool way to recover your data!!! This data back-up method can be used in both Windows and Linux data recovery. Thanks to the Author who documented the recovery process, it worked like magic on the First GO!

Step 1: Find an old USB flash drive

*I am using an old 2GB USB drive ūüôā

Old 2GB USB

Step 2: Download your OS from the following site:

http://peppermintos.com/

*32bit OS will do the job just fine, do not bother with 64bit OS.

Step 3: Download Lufus bootable USB maker from the following link and make a bootable usb using above two:

https://rufus.akeo.ie/

Step 4: Run Peppermint OS from the usb itself, running in live OS mode, connect an external USB storage and start data backing up/recovery

backup

Keep your bootable usb handy all times and have a fun!