Authenticate with a password
Password-based authentication is the simplest and most widely used authentication type in SSH. The connecting user is authenticated by a pair of its credentials, the username and the password.
To set up the component to use password-based authentication, simply assign your username and password to the relevant properties of your SSH component:
This should be done before calling Open().
client.Username = "user"; client.Password = "password";
If you configure AuthenticationTypes property yourself, you also need to ensure that SSH_AUTH_TYPE_PASSWORD flag is included in it. If you don't, just skip this step as that flag is switched on as per the component's default setup.
That's it. Upon connecting with Open() method the provided password will be used for authentication by the component automatically. Successful authentication is indicated by OnAuthenticationSuccess event being invoked.
If something goes wrong, OnAuthenticationFailed event is invoked instead, and a AuthType parameter of SSH_AUTH_TYPE_PASSWORD is passed to it. If no other authentication methods are available, this is followed by SSH error 114 (ERROR_SSH_NO_MORE_AUTH_METHODS_AVAILABLE).
Use AuthAttempts property to specify how many login attempts the user is allowed to make before the connection is terminated with 'no more authentication methods available' error. This is convenient if you ask your user for their password on the fly and do not want to re-establish a connection for each new password attempt. Just track the invocations of OnAuthenticationFailed(SSH_AUTH_TYPE_PASSWORD) event, asking the user to confirm their password and assigning it to the Password property each time the event is invoked.
Note: password-based authentication is always mixed up with keyboard-interactive one, as they are very similar from the user's point of view. If you've set up everything for the password-based authentication but still can't connect with error 114 (and other clients connect just fine), please try adding the SSH_AUTH_TYPE_KEYBOARD flag to AuthenticationTypes, as the server might be configured to use keyboard-interactive authentication and not the password-based one.