username/password prompting recognition - WeOnlyDo Discussion board

username/password prompting recognition (wodSSH / wodSSH.NET)

by birchsr, Wednesday, April 16, 2008, 14:08 (6066 days ago)

Hi there,

Ive been using the wodSSH module (VB6) with reasonable sucess for a couple of months now on a commercial program which is being shipped to many of my customers. I have a problem with 1 client, which i need a little help with, as i cant figure this one out!

basically, he's using telnet instead of SSH, and using DOS telnet he can access his *nix system fine on the PC in question, however wodSSH times out - just doesnt connect. it is not command prompt recognition, because it would fail later on within a login loop i have created (essentially a wrapper arround the recieve method).

the exact line on which the failure occurs is on .connect

could you tell me how the username and password questioning when initiating a connection is handled : does it trigger via regexp searching, or something else? does it expect defined keywords (i.e. login as: or login: ), and if so, can these keywords be changed, or is there some other way in which the initial give me your username question is handled?

I dont have the details yet on what the username prompting looks like yet, but i have a feeling it's non-standard, hence i'm opening this line of question now, just so i know where to go, should it proove so.

birchsr.

Re: username/password prompting recognition

by woddrazen, Wednesday, April 16, 2008, 15:42 (6066 days ago) @ birchsr

Hi birchsr.


You can try without using Login and Password Property. Using WaitFor Method to wait for Login and Password prompt and send info using Send Method.

Here is example:[code]
Set ssh1 = New wodSSHCom

ssh1.HostName = linux.weonlydo.com
ssh1.Authentication = authKeyboardInteractive
ssh1.Protocol = Telnet
ssh1.Blocking = True
ssh1.Timeout = 10
ssh1.Connect

'//Debug.Print ssh1.Receive
ssh1.WaitFor linux.weonlydo.com login:
ssh1.Send somelogin + vbLf
ssh1.WaitFor Password:
ssh1.Send somepassword + vbLf

Debug.Print ssh1.Receive
Debug.Print ssh1.Receive
Debug.Print ssh1.Receive[/code]
To find out which prompt is received and what should be added in WaitFor Method using Receive Method. Put Receive Method (maybe more than one) just after Connect Method and you can find out which prompt is received for Login and same should be done for Password. Put that Prompt in WaitFor Method and send login and password using Send Method.

You have issue with DOS Telnet server so maybe you should use vbCrLf instead vbLf in Send Method.

Let us know how it goes.


Regards,
Drazen

Re: username/password prompting recognition

by birchsr, Wednesday, April 16, 2008, 16:19 (6066 days ago) @ woddrazen

thanks for the quick response.

here's what the actual login process looks like, now i have got it:

[code]
telnet (P50)

Unauthorized use of this system is prohibited.
You should be aware that it may be a criminal offense to secure unauthorized access
to any program or data in the system or to make unauthorized modifications to it s contents.
If you are not authorized by management to access this system, log out now.

login : {username}
Contrase±a de {username}:{password}
[/code]

the thing which i notice is the password field doesnt have the word password in it! would this be what is 'tripping up' the connection?

taking your above example, i guess then i would not need to set ssh1.login or ssh1.password, becuase naturally i'm feeding the telnet session myself directly - that being the case, would it be considered wrong to set these properties in this example?

thought i had this part of my program sorted, guessed wrong :)

birchsr

Re: username/password prompting recognition

by wodDamir, Wednesday, April 16, 2008, 17:41 (6066 days ago) @ birchsr

Hi birchsr,

That's correct. In Drazen's sample you wouldn't need to set Login or password Properties. Basically, you will need to wait for this prompt, and then send the appropriate Login/Password. In this case, I guess that sending something like login:password would work...

Also, perhaps settings only Login property to the same value would work? Can you try?

Also, please note that I'm going blind here, since I can't test it on my own, so some of the suggestions may not work.

Regards,
Damba

Re: username/password prompting recognition

by birchsr, Thursday, April 17, 2008, 14:33 (6065 days ago) @ wodDamir

Hi woddrazen/wodDamir

well, ive followed your example, and my inhouse testing has prooved it works great, so thanks for that. ive had to put alot of branching in, because my program is designed to work with telnet, SSH1 and SSH2 user/pass authentication (keys is a later development), but hey, thats normal :)

i have made the decision that, should one field need fixing for a paticular customer, then both should be specified via a config file (already built in, just another addition), so i havent actually testing with only login set and passwor not set.

still assessing 'vblf vs vbcrlf'.

but other than that, job done (for now), thanks for the help.

birchsr