Request a password only if needed - WeOnlyDo Discussion board

Request a password only if needed (General questions)

by Marian, Thursday, April 29, 2010, 16:14 (5321 days ago)

Hello,
I'm testing SSH.NET for making a terminal program like SecureCRT.

I have noticed (with a sniffer) when connecting to my router using SecureCRT without providing any user name or password, it is establishing connection and then prompts for user name. after providing the username, some packets are sent then it prompts for password.

Now, I was wondering how could SecureCRT recognize when a user name is required and when a password ?

I suspect it's because of the cipher, but could not understand how this 3 states connection can be done with your component.

Thanks for the help.
Marian.

Re: Request a password only if needed

by woddrazen, Thursday, April 29, 2010, 17:02 (5321 days ago) @ Marian

Hi Marian,


Which protocol are you using in SecureCRT when you connecting to your server?


Regards,
Drazen

Re: Request a password only if needed

by Marian, Thursday, April 29, 2010, 17:26 (5321 days ago) @ woddrazen

Sorry if I was clear.
I'm using SSH2

Re: Request a password only if needed

by woddrazen, Thursday, April 29, 2010, 19:22 (5321 days ago) @ Marian

Marian,


Probably you server is using keyboard interactive authentication.

If you would like to use interactive session in wodSSH.NET you should select KeyboardInteractive authentication in wodSSH.NET Authentication Property.

When KeyboardInteractive is selected LoginChallenge Event should be fired. Inside LoginChallenge Event server will send some challenge text, you must reply with the correct responses to successfully authenticate.

You can do that using Args.Prompt which should be used to receive challenge prompt requested by the server. Using Args.Response you can send your response to server challenge prompt.

Let us know how it goes.


Drazen

Re: Request a password only if needed

by Marian, Thursday, April 29, 2010, 22:37 (5320 days ago) @ woddrazen

Hi Drazen,
Thanks for your reply.

The code I have is this:
[code] SSH client = new SSH();
client.ConnectedEvent += new SSH.ConnectedDelegate(client_ConnectedEvent);
client.CryptoInformationEvent += new SSH.CryptoInformationDelegate(client_CryptoInformationEvent);
client.DataReceivedEvent += new SSH.DataReceivedDelegate(client_DataReceivedEvent);
client.FingerPrintEvent += new SSH.FingerPrintDelegate(client_FingerPrintEvent);
client.LoginChallengeEvent += new SSH.LoginChallengeDelegate(client_LoginChallengeEvent);
client.Protocol = SSH.SupportedProtocols.SSHAuto;
client.Authentication = SSH.Authentications.KeyboardInteractive;
client.Connect( 10.100.100.1 );
[/code]

The client_FingerPrintEvent gets fired first, and then client_CryptoInformationEvent and finally client_ConnectedEvent with an error: Server returned the error: Invalid password!

Meaning the LoginChallenge is never called.
The server is actually a Cisco 7200, with ssh enabled (RSA)

Re: Request a password only if needed

by woddrazen, Thursday, April 29, 2010, 23:55 (5320 days ago) @ Marian

Marian,


Are you sure that keyboard interactive authentication is enabled on your server?

Can you maybe check your server settings and see if this type of authentication is enabled?

I just try it out using our server and it worked without any problem.


Drazen

Re: Request a password only if needed

by Marian, Friday, April 30, 2010, 08:19 (5320 days ago) @ woddrazen

Dear Drazen,
I'm not 100 sure keyboard interactive is enabled on my device, since I'm a programmer more than a network guy.
BUT, I am 100 SecureCRT and ZOC (another terminal software) both are able to connect, and request for password in the middle of the connection.

ZOC even allows me to enter a wrong password 3 times before the Cisco device is throwing me away.

I will try to setup some port forwarding so you will be able to access my router and check for yourself.

Many thanks for your will to help.
Marian.