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 08-28-2017, 01:03 PM
ashehata ashehata is offline
Registered User
 
Join Date: Aug 2017
Posts: 10
Remote Command option with SSH

Hello,

Is there any way to use the remote command option with SSH2 command?

crt.Session.ConnectInTab("/ssh2 /L #####/PASSWORD ######")




Thanks,
Reply With Quote
  #2  
Old 08-28-2017, 01:56 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 269
Hi ashehata,

Can you help me better understand what you are trying to accomplish? It appears that you are trying to open a second session to a different machine when you connect to the first, is that the case?

The remote command option is used to automatically run a command on the machine you are connecting to. Because the command is run on the remote server, not on your machine, using commands that are specific to SecureCRT will typically not work. The format of the command will depend on what type of machine you are connecting to. What type of server/Operating System are you connecting to?
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 09-01-2017, 07:56 PM
ashehata ashehata is offline
Registered User
 
Join Date: Aug 2017
Posts: 10
Dear Eric,

Well, I work at Internet service provider. In order to connect to routers and devices, I have to SSH on a server first, then I telnet to the devices. So my session settings as the following:




So I was wondering if there's an option to use the remote command session option to be used with the SSH command.

Code:
crt.Session.ConnectInTab("/ssh2 /L #####/PASSWORD ######")
I know that I could SSH2 on the server then I send telnet command as the following:

Code:
crt.Session.ConnectInTab("/ssh2 /L ##### /PASSWORD ##### 10.110.165.70")
crt.Screen.WaitForString("$")
crt.Screen.Send("telnet 172.16.15.142")
crt.Screen.Send("\n")
But the issue is that sometimes I need to clone the session. So it clones the server session, not the router's session. So if there's a way that I could use the remote command option in my script that would be great.

Thanks.
Reply With Quote
  #4  
Old 09-05-2017, 09:24 AM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 269
Hi ashehata,

If your server allows it, you may be able to use SecureCRT's Dependent Session feature. This would allow you setup a Session as if going directly to the end device and have SecureCRT automatically route traffic through your “gateway server”.

Step 1: Create a “JumpHost” session Set up a session that will connect with SSH2 to your jump host server. Test your jump host session to ensure that you are able to successfully connect and authenticate. Then, close that session’s tab/tile.

Step 2: Create your secondary host session(for example: D1) Set up a new session that will be used to connect to your secondary host. For example, if your secondary host’s IP address is 10.0.0.1, you would have: Hostname: 10.0.0.1 Username: secondary-username etc.

Step 3: Edit your secondary host session to specify a dependent session to use as firewall/proxy Edit your newly-created session (right-click it in Session Manager and chooseProperties). - In the SSH2 category, select theFirewall drop-down and chooseSelect Session... - When theSelectSSH2 session window appears, select the “JumpHost” session you created earlier in step 1 above. - Save your changes to the session configuration

Step 4: Use your Secondary Host session to connect and test it out. Once you’ve created your secondary session and set its Firewall field to point to the JumpHost session, connect using your secondary session. SecureCRT will first (automatically, and behind the scenes) establish a connection to the JumpHost session. Once a connection to the jump host has been established, SecureCRT will ask the jump host server to establish a connection on its behalf to the secondary host. If you enableTrace Options from SecureCRT’s mainFile menu prior to attempting your connection, you'll be able to see debugging information that reveals the behind-the-scenes handshaking going on.

Using these steps are you able to get the behavior you're looking for?
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #5  
Old 09-06-2017, 10:34 AM
ashehata ashehata is offline
Registered User
 
Join Date: Aug 2017
Posts: 10
Hello Eric,

Thanks, I think the above steps are to be done via SecureCRT GUI right ?

But what I am asking for if there's a command to use while scripting or not? And if there is, what it is?

Thanks,

Last edited by ashehata; 09-06-2017 at 06:53 PM.
Reply With Quote
  #6  
Old 09-06-2017, 01:39 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 269
Hi ashehata,

I'm sorry I misunderstood your request.

If you would like to continue to use the same Remote command option when running a script it would look like:

Code:
  objConfig = crt.OpenSessionConfiguration("My Session Path")
  objConfig.SetOption("Use Shell Command", True)
  objConfig.SetOption("Shell Command", "telnet 172.16.15.142")
  objConfig.ConnectInTab()
Another option would be to configure your sessions as you want them in the GUI then launch the session instead of manually configuring your settings. That would look something like:

Code:
crt.Session.ConnectInTab("/S SessionName")
Does this help?
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #7  
Old 09-07-2017, 07:05 AM
ashehata ashehata is offline
Registered User
 
Join Date: Aug 2017
Posts: 10
Hi Eric,

Thanks a lot. it worked with me but I have another issue while cloning the tab with the logon that I have to enter them manually.

So I am wondering if it is possible that I set the automate logon option through my script by using objConfig.SetOption syntax?

Reply With Quote
  #8  
Old 09-07-2017, 09:38 AM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 269
Hi ashehata,

No, it's not currently possible to manipulate logon actions through scripting. Logon actions simply waits until it sees a set string, when it does it sends a set response. This can be accomplished using WaitForString and SendString.

Code:
crt.screen.WaitForString("ogin:")
crt.screen.SendString "YourUsername" & vbcr
crt.screen.WaitForString("assword:")
crt.screen.SendString "YourPassword" & vbcr
You may also need to set your screen to synchronous, without seeing your full code I can't be sure if or where you may have already set this. It would look like:

Code:
crt.screen.synchronous = true
I have recorded your interest in scripting logon actions in our database of SecureCRT feature requests so that the product director can evaluate it for possible inclusion in a future release.

Should a version of SecureCRT become available with this feature, we will be sure to let you know.

Does this help?
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730

Last edited by ekoranyi; 09-07-2017 at 10:15 AM.
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 10:42 AM.