Print this Post

Python + XLRD SecureCRT Import

First of all a disclaimer. I am NOT a programer. I promise this could probably be cleaned up considerably by someone that actually does programming. Also, It may require some tweaking to work on your system. This is tested on Mac 10.12.3 and SecureCRT 8.1*

I’ve always loved using SecureCRT. I often find myself needing to add anywhere from a small to a large number of sessions to my list. Especially in my current role. I had remembered in my past at an old roll where I used Windows as my primary OS (work issued) that I had discovered a forum that had a python and VBS script to import sessions out of a CSV. Now that I am running on Apple I sought out that old forum and grabbed the python script. Drats!!! The python script doesn’t work on my new version of SecureCRT for Mac (8.1). Then I started thinking. Most of the time clients give me a nice spreadsheet of IP addresses. This got me thinking, why not write my own that uses Excel. So here it is!


First off, you need to install XLRD into python. I used easy_install but pip may be an option for you as well.

Second, create a folder for the script and it’s template file used to import sessions. This is where you will place the below two files named SecureCRTImport.py and template.ini





This next part is simple. Create or modify a spreadsheet so the first four columns are as follows:

Sessions Name

Make sure the columns are in this order and then begin populating the data. Protocol may be (SSH2, SSH1 or Telnet). You may do nested folders as well. Here is an example screenshot.

Screen Shot 2017-03-07 at 2.31.48 PM

The next step is to open terminal and move to the folder you stored your scripts in and run this command

python SecureCRTImport.py

This will launch a dialog box asking you to select your .xlsx file.

Screen Shot 2017-03-07 at 2.35.24 PM

Once it reads your xlsx file it will indicate how many sessions it found and import them into SecureCRT into the folders you described.

Screen Shot 2017-03-07 at 2.36.35 PM

Now if we launch SecureCRT we will see the new sessions.

Screen Shot 2017-03-07 at 2.39.42 PM

Matt Ouellette is a certified information technology professional residing in Southwest Michigan. His technology findings and advice can be found on his PacketPilot blog. Mr. Ouellette spent 4 years as an I.T. Technician before stepping into a Network Engineer role at Bronson Health Group. Since completing his Associates Degree in Network Administration Matt has taken a head on approach to career enrichment through obtaining credentials such as CCNP, CCNA Voice, MCSA: Server 2008, and VCP5. This passion for continued learning allows him to deliver up to date quality technical solutions.

Permanent link to this article: http://www.packetpilot.com/python-xlrd-securecrt-import/