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 12-23-2008, 03:36 AM
seteshpl seteshpl is offline
Registered User
 
Join Date: Nov 2008
Posts: 10
SSH Connection

Hello,

I want to connect through a script by using SSH to my device.
The problem is that it connects only when I set up key-authentication as Diffie-Helman. So when I create new sessions there is no problem (I just put diffie-helman on top of key exchange possibilities in SSH settings) but... how to do this automatically in the script?

my current connection line is following:

Code:
cmd = "/SSH2 /L " & user & " /PASSWORD " & passwd & " " & ipAddress
Thanks, Mark
Reply With Quote
  #2  
Old 12-23-2008, 09:41 AM
kbarnette kbarnette is offline
VanDyke Technical Support
 
Join Date: Aug 2007
Posts: 587
Hi Mark,

I have deleted my original post and provided what should be an answer more specific to your question.

There may be a few ways to accomplish this, depending on the requirements of your environment.

One way would be to configure your Default session to use the 'Diffie-Hellman' key exchange method. Once the Default session has been configured to use 'Diffie-Hellman' all new sessions (and ad-hoc connections) will use this key-exchange method.
The 'Default' session can be modified by clicking the 'Edit Default Settings' button in the 'General/Default Session' category of the Global Options dialog.

Would modifying your 'Default' session be an option in your environment?
Reply With Quote
  #3  
Old 12-30-2008, 06:47 AM
seteshpl seteshpl is offline
Registered User
 
Join Date: Nov 2008
Posts: 10
Hello,

Yes, it is the solution . thank you for your help - now it works great!

regards, Mark
Reply With Quote
  #4  
Old 01-07-2009, 06:53 PM
figueroa figueroa is offline
Registered User
 
Join Date: Jan 2009
Posts: 4
I have this problem, i try to make a funtion, for connect to many server but this servers normaly change the RSA key
the idea is:
1. execute ssh -l user server
2. Wait string
2.a if it is "assword:" send password
2.b if it is "Are you sure you want to continue connecting (yes/no)?" send yes
2.b.1 if it is "assword:" send password
Easy , but this script don't work

Code:
Sub LoginServer(servername,username,password) 

 	crt.Screen.Send "ssh -l "& username &" "& servername &""& Chr(13)
	If crt.screen.WaitForString("assword:", 2) <> True Then 

		crt.Screen.Send password & Chr(13)

	Else 
		If crt.screen.WaitForString("Are you sure you want to continue connecting (yes/no)?", 2) <> True Then 

			crt.Screen.Send "Yes" & Chr(13)

			If crt.screen.WaitForString("assword:", 2) <> True Then 

				crt.Screen.Send password & Chr(13)

			Else 
				
				CodeError = 2

			End If 
		Else 

			CodeError = 1

		End If 
	End If 
End Sub
this example the output
Code:
example	
test@test-monitor:~$ ssh -l testusername 12.34.56.79
The authenticity of host '12.34.56.79 (12.34.56.79)' can't be established.
RSA key fingerprint is 21:11:4e:78:6a:76:46:e8:ba:6c:a7:32:0c:b2:c3:fd.
Are you sure you want to continue connecting (yes/no)? testpassword
Please type 'yes' or 'no': ssh -l test 12.34.56.80
Please type 'yes' or 'no':
Any idea...
Reply With Quote
  #5  
Old 01-08-2009, 03:26 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi figueroa,

The block of code that you posted has a couple of problems.
  • The boolean logic is failing because WaitForStrings returns "True" if a string is found, and you have set the code to not equal "True".
  • The second problem is that while waiting for a password prompt for 2 seconds in the first If the remote has already sent the "(yes/no)?" prompt to the screen, so the Else If can never find the "(yes/no)?" prompt.

Please see the example code below for a way to resolve the code problems mentioned above.

Code:
Sub LoginServer(servername,username,password) 

    crt.Screen.Synchronous = True
    crt.Screen.Send "ssh -l " & username & " " & servername & "" & vbcr
    
    Do 
        nResult = crt.Screen.WaitForStrings("ssword:", "(yes/no)?", 5)
        
        Select Case(nResult)
        
        Case 1
            
            crt.Screen.Send password & vbcr
            Exit Do
            
        Case 2
            
            crt.Screen.Send "yes" & vbcr
            
        Case 0 'We timed out at the WaitForStrings
            
            CodeError = 1
            Exit Sub

        End Select
        
    Loop

End Sub
Does this information help resolve the scripting problem you have encountered?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #6  
Old 01-12-2009, 07:12 PM
figueroa figueroa is offline
Registered User
 
Join Date: Jan 2009
Posts: 4
Smile

Yes .. thank you!!!
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 01:32 PM.