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 06-06-2014, 09:20 AM
mikit mikit is offline
Registered User
 
Join Date: Mar 2012
Posts: 38
connect via SSH without using username

Hello,

I am trying to write a script to connect to a device via SSH without using the username, but just password. Is it possible?

Here is the ssh connection string I am using to connect with the username:
cnxnString = "/SSH2 /ACCEPTHOSTKEYS /L " & user & " /PASSWORD " & pass & " /C 3DES /M MD5 /M SHA1-96 " & ip


One more thing. I am running a script on bunch of devices and some of them are connectable via SSH with username/password, but some of them only with password. Below is the section of my script I use to connect to devices. First it tries "user/pass SSH" and then if this is not successful I want it to use "only pass SSH". Issue is, that on the first try, "user/pass SSH", when pass is not correct, dialog pop-ups with incorrect pass error. I click OK, and there is another dialog asking for user/pass. I have to click Cancel so script moves to the next connection option which is "only pass SSH". Is it possible to automatically click on OK and Cancel on those dialogs?

Script:
cnxnString = "/SSH2 /ACCEPTHOSTKEYS /L " & user & " /PASSWORD " & pass & " /C 3DES /M MD5 /M SHA1-96 " & ip
crt.Screen.Synchronous = True
crt.Session.Connect cnxnString

'if SSH2 is not working, try telnet
If crt.Screen.WaitForString("#", 15) <> True then
crt.Session.Disconnect

'Connect via SSH2 with enable pass
cnxnString = "/SSH2 /ACCEPTHOSTKEYS /L " & "" & " /PASSWORD " & enableP & " /C 3DES /M MD5 /M SHA1-96 " & ip
crt.Screen.Synchronous = True
crt.Session.Connect cnxnString

If crt.Screen.WaitForString(">", 15) <> True then
crt.Session.Disconnect
.
.
.

I know that Cases would be a better option :-)
Reply With Quote
  #2  
Old 06-06-2014, 10:32 AM
mikit mikit is offline
Registered User
 
Join Date: Mar 2012
Posts: 38
I figured out the no username part:

cnxnString = "/SSH2 /ACCEPTHOSTKEYS /L " & vbcr & " /PASSWORD " & enableP & " /C 3DES /M MD5 /M SHA1-96 " & ip
Reply With Quote
  #3  
Old 06-06-2014, 10:35 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi mikit,

I am glad to hear that you figured our the no username part. I don't have any devices for testing that don't require a username.
Quote:
Is it possible to automatically click on OK and Cancel on those dialogs?
It is not currently possible to interact with GUI dialogs in a script, but it is possible to modify the session to display the authentication prompts in the terminal window.

You may consider taking a look at the following example script:
https://forums.vandyke.com/showthrea...7294#post37294
Between lines 103 and 122 in the VBScript version, you can see how to programmatically enable the prompts to appear in the terminal window.

Does this help?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #4  
Old 06-06-2014, 11:31 AM
mikit mikit is offline
Registered User
 
Join Date: Mar 2012
Posts: 38
I've tried this, but not working:

Set objConfig = crt.OpenSessionConfiguration("Default")
objConfig.SetOption "Auth Prompts In Window", True

'Connect via SSH2
cnxnString = "/SSH2 /ACCEPTHOSTKEYS /L " & user & " /PASSWORD " & pass & " /C 3DES /M MD5 /M SHA1-96 " & ip
crt.Screen.Synchronous = True
crt.Session.Connect cnxnString

And also this:
Set objConfig = crt.Session.Config
objConfig.SetOption "Auth Prompts In Window", True
Reply With Quote
  #5  
Old 06-06-2014, 11:48 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Thanks for the update mikit.

What version of SecureCRT are you using?

How is the script not working?

Do you see an error message when running the script?

Any additional details you can provide may be useful.
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #6  
Old 06-06-2014, 11:57 AM
mikit mikit is offline
Registered User
 
Join Date: Mar 2012
Posts: 38
I am using v 6.5.0.

There is no error message. Script is working but it is still showing dialog box for authentication. I've tried also False.
Reply With Quote
  #7  
Old 06-06-2014, 12:27 PM
mikit mikit is offline
Registered User
 
Join Date: Mar 2012
Posts: 38
Ok, now the autheticatio in terminal is working, I mean I was able to turn that option on, but it got stuck on crt.Session.Connect cnxnString. Probably cnxn strin is not OK.
Reply With Quote
  #8  
Old 06-06-2014, 03:40 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi mikit,

I looked more closely at the connection string, and you are specifying two MACs. I guess my question is why are you specifying the Cipher and MAC? The client and server will negotiate both the Cipher and MAC.

It seems like you could use the following successfully:
"/SSH2 /ACCEPTHOSTKEYS /L " & user & " /PASSWORD " & pass & ip
Does this help?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #9  
Old 06-10-2014, 08:04 AM
mikit mikit is offline
Registered User
 
Join Date: Mar 2012
Posts: 38
Hi Todd,

when I am not using authentication in terminal window, cnxn string works OK. I am using the script to gather data form various type of devices and some are using md5. some sha, some 3des for ssh key, that's why I have them there. As I said, string works fine when I am not trying to use authentication in terminal window.

Issue is, that I am not getting Username/password promt in terminal window when terminal window authentication is enabled. But this happens only when I try to use script. If I connect directly, quick connection, then there is no problem and it asks me for username and password:

Please enter login information for 10.54.77.8.
Username: abcd
Password:
Reply With Quote
  #10  
Old 06-10-2014, 09:13 AM
mikit mikit is offline
Registered User
 
Join Date: Mar 2012
Posts: 38
Hi Todd,

now it is working. Below is the part of the script that I am using. So it tries to connect with username/password. It connects to device and waits for #, but as password is not correct, # never appears so after 15 seconds it moves to "only pass SSH".

Code:
Set objConfig = crt.OpenSessionConfiguration("Default")
objConfig.SetOption "Auth Prompts In Window", True
objConfig.Save
			
	'Connect via SSH2
	cnxnString = "/SSH2 /ACCEPTHOSTKEYS /L " & user & " /PASSWORD " & pass & " /C 3DES /M MD5 /M SHA1-96 " & ip
	crt.Screen.Synchronous = True
	crt.Session.Connect cnxnString

	If crt.Session.Connected = True Then
		If crt.Screen.WaitForString("#", 15) <> True then
		crt.Session.Disconnect
					
		'Connect via SSH2 with enable pass
		cnxnString = "/SSH2 /ACCEPTHOSTKEYS /L " & vbcr & " /PASSWORD " & enableP & " /C 3DES /M MD5 /M SHA1-96 " & ip
		crt.Screen.Synchronous = True
		crt.Session.Connect cnxnString

Thanks a lot for your help!


Edit: actually, it is not that simple as I thought... best would be if it shows the username/password promt as mentioned one post above.

Last edited by mikit; 06-10-2014 at 09:21 AM.
Reply With Quote
  #11  
Old 06-10-2014, 02:53 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi mikit,

I am glad to hear that you have a solution.

You may want to take a look at another example script:
https://forums.vandyke.com/showthrea...7087#post37087
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
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 04:11 PM.