Discuss this help topic in SecureBlackbox Forum
Authenticate with a key
Key-based SSH authentication uses a locally stored user's private key to authenticate the user to the server.
Setting up public key authentication (that's the official name for it; it is OK to use 'public key' term here despite the fact that the *private* key is actually used, as the term 'public key' refers to 'public key authentication' concept of cryptography rather than the user's public key) is performed in the following steps:
C#:
TElSSHMemoryKeyStorage storage = new TElSSHMemoryKeyStorage();
storage.Add(key);
C#:
client.KeyStorage = storage;
C#:
client.AuthenticationTypes = client.AuthenticationTypes | SBSSHConstants.Unit.SSH_AUTH_TYPE_PUBLICKEY;
That's it. Upon connecting with Open() method the key should be taken and 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_PUBLICKEY 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).
If you have a number of keys for the user and do not know which one to use, or you just prefer to load the private key only when it is actually needed, you may choose to use on-demand key provision approach: