Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 07-22-2019, 04:33 PM
lionelrichie lionelrichie is offline
Registered User
 
Join Date: Jul 2019
Posts: 2
Continuous delivery of SecureCRT session file

I want to be able to continuously compile our CSV of devices into a SecureCRT session file format that users can check out of git. Every time someone updates our CSV of devices, I would like a new SecureCRT session file generated. Our CI/CD process can take care of that, assuming I can offer automation for the SecureCRT side. These users will be primarily Windows 10 users. The host I want to do this continuous delivery (read: conversion) on is a Linux box with no GUI.

There is lots of discussion on the forums and web about the VBS and Python scripts reading in CSVs but they depend on an interactive client experience to import the sessions given a data file(CSV).

Some questions:

a) Should I be installing the Linux client package on the Linux host doing the continuous conversion in order to have access to the libraries needed? Are they available through pip? How do I include them in a Python script on that host?

b) What methods am I using to generate that session file, and what format is it producing (ini?)

thanks!
Reply With Quote
  #2  
Old 07-23-2019, 09:50 AM
jjh jjh is offline
VanDyke Customer Support
 
Join Date: Feb 2004
Posts: 799
Hello lionelrichie.

Thank you for contacting us. As you have alluded to, there isn't a mechanism that is built into SecureCRT to generate sessions based on a csv file. We offer a Python version and a VBScript version of a script that can generate SecureCRT sessions based on a csv file, which you can find on the following page on our forums:

- https://forums.vandyke.com/showpost....89&postcount=1

We offer a video on our YouTube channel that explains how to use the script, which you can find on the following web page:

- https://www.youtube.com/watch?v=f7nM...ature=youtu.be

You will need to run the script from SecureCRT, which is a manual process, so if you choose to use the script, you will need to install SecureCRT on the machine where the sessions are to be generated. What it does is generate the .ini files that SecureCRT uses as sessions. The .ini files that are generated from the csv file are stored in a folder named "Sessions", that is found within the user's Config folder.

Since you are looking for a way to automate this process, it will be up to you to decide how you are going to do it. It sounds like you will need to find a way to monitor the .csv file for updates. Then, once the file has been updated, if you find a way to trigger something to happen, the event that happens could be launching SecureCRT with the /script flag so that the session generation script can run.

Also, the script generates all of the sessions from the .csv file each time it is run, but it will use a timestamp if duplicate sessions are created. You will have to take this into account so that you can decide whether or not it will make sense to generate all of the sessions every time the script is run.

Perhaps, every time you wanted to add new hosts, instead of adding them to an existing .csv file, you could create a new file and run the script against it. That way you wouldn't have to worry about how to deal with duplicates.

If you would like me to create an entry for you in our feature request database for a built in way to generate sessions based on a csv file, please send e-mail to support@vandyke.com referencing this forum thread so that I can include your e-mail address in the request.

Thanks.

JJH
Reply With Quote
  #3  
Old 07-23-2019, 04:28 PM
lionelrichie lionelrichie is offline
Registered User
 
Join Date: Jul 2019
Posts: 2
Thanks - this is helpful. Here is another consideration I could use your feedback on: when someone consumes a future version of the address book / session ini, how do we allow them to merge changes so they don't lose their customizations? Example: I add two hosts to this csv->ini compilation process on my Linux builder, it spits out a new ini, someone grabs that ini - so what happens to customizations they have made to sessions already imported? I am thinking about things like username and password.

This might be asking more of the tool than is currently available but I am probing to see what is possible, and whether this is worth the effort.
Reply With Quote
  #4  
Old 07-24-2019, 06:02 AM
ogun ogun is offline
Registered User
 
Join Date: Sep 2013
Posts: 15
We do basically what you are asking for at our place. I wrote a python script that takes JSON data files and generates sessions accordingly.

It was posted on the forum previously https://forums.vandyke.com/showthread.php?t=13019

When it runs, it creates a diff of existing sessions and new sessions. It will then create all the new sessions and ask if it should delete sessions no longer in the data file.
It will not touch already existing sessions based on the session name as the key, if you want to generate them again you'd have to delete the session and then run the script.
When it creates a session it copies the default session, sets the parameters and then saves it as a new session.

Feel free to use as inspiration or as is, I'll be happy to answer any questions as well.
Reply With Quote
  #5  
Old 07-24-2019, 09:45 AM
jjh jjh is offline
VanDyke Customer Support
 
Join Date: Feb 2004
Posts: 799
Each user has a Config folder that stores their settings. Inside the Config folder are various folders and files including the Global.ini file, which stores you global settings and a folder named "Sessions", which stores the .ini files associated with your sessions.

We offer an export/import tool under the Tools menu in SecureCRT. You have the option of exporting and importing any combination of your Global Options, Sessions, License and Scheduled Tasks (If you are using the Windows version). When you use the export tool, SecureCRT will create an xml file containing all of the information you choose to export. When you use the import tool, you need to specify that xml file. Duplicates will be ignored. So files with the same name on both machines will be omitted. If you have a session named "Session1" on the machine that is doing the export and the machine doing the import also has a session named "Session1", that session will not be imported. It is important to know that if you are using a Configuration Passphrase when you use the export tool, you will need to provide that configuration passphrase when you do the import.

Another thing to be aware of is that there is a setting in the Configuration Paths category of your Global Options labeled "Store personal data separately". If you enable that setting, SecureCRT will remove your saved credentials from your sessions and store them in a separate folder. That setting will make it possible for you to share your sessions without sharing your credentials.

If you don't want to use the Export and Import tools, you can simply make any new .ini files available for sharing and instruct your users to copy them into their "Sessions" folder. Once the end user owns their own copy of the session.ini files, they can save their own passwords or customize the sessions in whatever way they want.

JJH
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 03:14 AM.