#1
|
|||
|
|||
Jump Host to Remote Server -All-Script Challenge
Okay, I've searched all weekend and can't figure out how to solve this.
== 600 SERVERS TO GET DATA FROM == ================================== 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. == CAN SCRT DO IT? == ===================== 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. == DATA LOOKS LIKE THIS == ========================== 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 10.1.1.1 freda oi43uomfw 172.20.1.1 admin1 345d5 10.1.1.1 freda oi43uomfw 172.20.1.2 roberta spdoowu598 10.1.1.1 freda oi43uomfw 172.20.1.3 admin1 l6yhl8ik6 10.1.1.1 freda oi43uomfw 172.20.1.4 admin3 wwfwcf5refg 10.1.2.1 admin iuycowiuy 172.20.2.1 webms4 4edyff5ys5y 10.1.2.1 admin iuycowiuy 172.20.2.2 adminxx r7h8htl8o 10.1.2.1 admin iuycowiuy 172.20.2.3 Adminul das4fasy646y 10.1.2.1 admin iuycowiuy 172.20.2.4 Bharlety df5u6gi7hhi 10.1.2.1 admin iuycowiuy 172.20.2.5 admintx ca4f4lkjl ... == POSSIBILITY? == ================== 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. Then: Code:
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) disconnect send exit (from JumpHost) disconnect Last edited by VanDyke82nev; 12-03-2017 at 06:49 PM. |
#2
|
|||
|
|||
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. Code:
# $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 Next objExcel.Quit() Does this help you get the functionality you're looking for?
__________________
Thanks, --Eric VanDyke Software Technical Support support@vandyke.com (505) 332-5730 Last edited by bgagnon; 12-04-2017 at 03:43 PM. |
#3
|
|||
|
|||
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. THANK YOU ERIC! |
#4
|
|||
|
|||
Hi VanDyke82nev,
I'm glad I could help. I look forward to hearing your results.
__________________
Thanks, --Eric VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
![]() |
Tags |
firewall , jump host , port forwarding , ssh hop |
Thread Tools | |
Display Modes | Rate This Thread |
|
|