VanDyke Software Forums

VanDyke Software Forums (
-   Scripting (
-   -   Jump Host to Remote Server -All-Script Challenge (

VanDyke82nev 12-03-2017 07:42 PM

Jump Host to Remote Server -All-Script Challenge
Okay, I've searched all weekend and can't figure out how to solve this.


I have 600 servers distributed across 75 branch offices. Each branch office has their own jump server. The passwords are all different. I have to pull statuses (just run a couple commands) from all 600 servers.


Is it possible to use SecureCRT to log into these with a script?

I set up a saved SCRT session to one of the jump servers, then did dynamic port forwarding. Then I set up a session to one of the target servers, specifying the firewall from above. It worked.

But the problem is there is no way to import the 75 jump hosts or 600 servers with passwords into SCRT as saved sessions, and manually entering all 675 the passwords isn't a whole lot easier than just doing it all manually.


So I need to run it all from a script. I have it already in a spreadsheet. Like this (fake but similar data)

Jump_IP JH-user JH-pass Server IP srv-usr srv-pass freda oi43uomfw admin1 345d5 freda oi43uomfw roberta spdoowu598 freda oi43uomfw admin1 l6yhl8ik6 freda oi43uomfw admin3 wwfwcf5refg admin iuycowiuy webms4 4edyff5ys5y admin iuycowiuy adminxx r7h8htl8o admin iuycowiuy Adminul das4fasy646y admin iuycowiuy Bharlety df5u6gi7hhi admin iuycowiuy admintx ca4f4lkjl


Can I use the /firewall option?

I would have to guess I can set the port forwarding at the cmd line somehow, but can't find how.


connect ssh2 JumpHost Session username password etc. -port forwarding stuff
Wait for command prompt
connect ssh2 Server  session usnername password etc. -specify firewall above? or use port
wait for command prompt

run version command
wait for results

send exit (from Server)
send exit (from JumpHost)

ekoranyi 12-04-2017 02:50 PM

Hi VanDyke82nev,

Is your goal to import SecureCRT sessions or to gather the data from the end devices? Currently it is not possible to import passwords into SecureCRT sessions. If however, you do not need to save connections, we may be able to help with getting the data from your end devices.

Using the example data you provided I've mocked up a script that would read the data from Excel and connect to the JumpServer, once connected you could then issue the command the JumpServer requires to connect to the end device also using the data read from your Excel sheet.


# $language = "VBScript"
# $interface = "1.0"

strFilePath = "C:\Path\to\ServerList.xlsx"

Set objExcel = CreateObject("Excel.Application")
Set objWkbk = objExcel.Workbooks.Open(strFilePath)
Set objSheet = objWkbk.Sheets(1)

For Each objRow in objSheet.Rows
    If objRow.Row > 1 Then
        strJumpAddr = objRow.Cells(1,1).value
        strJumpUser = objRow.Cells(1,2).value
        strJumpPass = objRow.Cells(1,3).value
        strSrvrAddr = objRow.Cells(1,4).value
        strSrvrUser = objRow.Cells(1,5).value
        strSrvrPass = objRow.Cells(1,6).value

        If strJumpAddr = "" Then
            Exit For
        End If
        'Example of using the data read from Excel
        'crt.Dialog.MessageBox(strJumpAddr & vbcrlf &_
        '    strJumpUser & vbcrlf &_
        '    strJumpPass & vbcrlf &_
        '    strSrvrAddr & vbcrlf &_
        '    strSrvrUser & vbcrlf &_
        '    strSrvrPass & vbcrlf)
        Set objNewTab = crt.Session.ConnectInTab("/SSH2 /PASSWORD " &_
                                                strJumpPass & " " &_
                                                strJumpUser & "@" & strJumpAddr)
        'Wait for screen to stop changing
        'Command jump host requires to connect to end device
        'crt.Screen.Send("ssh " & strSrvrUser & "@" & strSrvrAddr)
        'Authentication for end device
        'Wait for screen to stop changing
        'Commands to collect your needed data
    End If


The example script found here includes functions that demonstrate handling authentication and waiting for the screen contents to stop changing before sending the next command.

Does this help you get the functionality you're looking for?

VanDyke82nev 12-04-2017 03:01 PM

Hi Eric,

It would be great if I could have them all saved as sessions too, but the main task at hand is going to each of the 600 servers and pulling the versions of an process.

Thank you so much for the script. I'm going to have to study it, and understand what you are doing, but from your description it sounds like what I need. I may have a question or two later.


ekoranyi 12-04-2017 04:12 PM

Hi VanDyke82nev,

I'm glad I could help. I look forward to hearing your results.

All times are GMT -6. The time now is 11:17 AM.