#1
|
|||
|
|||
Scripting Multiple Sessions Through a Jumpbox
I am very new to scripting in SecureCRT and am currently editing a .bat file for connecting to multiple devices at once. It requires a plain text login and password which I desperately need to get away from. This is currently the format of the .bat file which the hostnames are edited a few times a night to connect to the specific devices. This will open each device in a seperate tab and allow me to run various other .vbs files or just type out commands.
cd \Program Files\VanDyke Software\Clients SecureCRT /T /SSH2 /ACCEPTHOSTKEYS /PASSWORD XXXXXXXX /L user hostname1 SecureCRT /T /SSH2 /ACCEPTHOSTKEYS /PASSWORD XXXXXXXX /L user hostname2 SecureCRT /T /SSH2 /ACCEPTHOSTKEYS /PASSWORD XXXXXXXX /L user hostname3 SecureCRT /T /SSH2 /ACCEPTHOSTKEYS /PASSWORD XXXXXXXX /L user hostname4 SecureCRT /T /SSH2 /ACCEPTHOSTKEYS /PASSWORD XXXXXXXX /L user hostname5 SecureCRT /T /SSH2 /ACCEPTHOSTKEYS /PASSWORD XXXXXXXX /L user hostname6 SecureCRT /T /SSH2 /ACCEPTHOSTKEYS /PASSWORD XXXXXXXX /L user hostname7 SecureCRT /T /SSH2 /ACCEPTHOSTKEYS /PASSWORD XXXXXXXX /L user hostname8 SecureCRT /T /SSH2 /ACCEPTHOSTKEYS /PASSWORD XXXXXXXX /L user hostname9 SecureCRT /T /SSH2 /ACCEPTHOSTKEYS /PASSWORD XXXXXXXX /L user hostname0 We have a jumpbox with a built in script for connecting to devices in the same manner and I am trying to figure out how to build a more efficient .bat or .vbs to perform this task. cd \Program Files\VanDyke Software\Clients SecureCRT /T /S "my_jumpbox" Would be the example for connecting to the jumpbox. It also has a built in script for connecting to devices and because it uses an SSH Key no login or pass is needed in a plain text file. Below is the example output needed to connect to devices. my_jumpbox$ ym hostname1 That will allow me to connect to the device from the jumpbox without the need to enter a login/pass. I am just hitting a wall on trying to get this scripted into a .bat or .vbs file or both so that I can get away from the aforementioned process of saving a pass in a plain text file. Whether anyone can just point me in the right direction or provide an example output for opening the jumpbox via multiple tabs at once with send strings would help. The goal is having only one file that would have to be edited with the hostnames which I could accomplish with replace strings or another formula. |
#2
|
|||
|
|||
Hi shea_nb,
It sounds like an interesting problem you're trying to solve. I cam imagine several ways to tackle this one. Can you tell me a little more about your use case? It looks like you're using ad-hoc connections rather than saving a session for each host you're connecting to, is there a reason you're not saving sessions? Is there a reason you're launching from the command line rather than from inside SecureCRT? It does appear that you have a session saved for your jump box named my_jumpbox. One option would be to configure this session to use a logon script. The script would read in a hostname argument and use it to build the appropriate command to send to the jump box. This script might look something like: Code:
# $language = "VBScript" # $interface = "1.0" If crt.Arguments.Count > 0 Then strHostname = crt.Arguments(0) Else crt.Dialog.MessageBox "No Hostname Provided" End If 'Wait for the prompt to appear crt.Screen.WaitforString "my_jumpbox$" 'Send the command to connect to host crt.Screen.Send("ym " & strHostname & vbcr) This would allow you to launch SecureCRT from the command line using: Code:
SecureCRT.exe /T /Arg hostname1 /S my_jumpbox Code:
set HostARG=%1 "c:\Program Files\VanDyke Software\Clients\SecureCRT.exe" /T /ARG %HostARG% /s my_jumpbox Does this help get you the behavior you're looking for?
__________________
Thanks, --Eric VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#3
|
|||
|
|||
Yes that does help, ty.
|
![]() |
Tags |
jumpbox jump box , multiple at once , scripting |
Thread Tools | |
Display Modes | Rate This Thread |
|
|