Show/Hide Toolbars

Inventu Viewer+ .NET Programmer's Reference

Navigation: HostConnection Class > Methods

setSSHKey Method

Scroll Prev Top Next More

Set the active SSH Key and optional SSH Pass-phrase to use for a new connection to an SSH Server.

 

 

bool HostConnection.setSSHKey(String sshKey)

bool HostConnection.setSSHKey(String sshKey, String passPhrase)

 

 

Arguments

 

HostConnection

 Required. HostConnection object.

 

sshKey

Required. The private key or private key file full path to be used for the new SSH connection. If passPhrase is included, the key is assumed to be encrypted binary data and can only be processed as a file, and the sshKey parameter is the full path to that binary file.  When passPhrase is omitted or NULL, the key is assumed to be text with examples below.
 
Here are examples of the text of the key as may be found in a generated key file which starts and ends with text such as:
 
ssh-rsa [key contents] =
 
       --or--
 
---- BEGIN RSA PRIVATE KEY ----[key contents]=---- END RSA PRIVATE KEY ----

 

passPhrase

Optional. If the key is inside a binary file on disk and encrypted with a passphrase, this will be needed to de-crypt the key file, otherwise do not include as a parameter.

 

Remarks

 

setSSHKey must be called after a new HostConnection object is created and before the connect method is called.

 

Returns false if the HostConnection is invalid, true if the HostConnection is valid and has not been connected yet.

 

To work properly, the HostConnection object hostName must match an existing SSH Server with a configuration setup for credential use matching the server being connected to.

 

The following sample sets the key using an unencrypted string read from a DB or other configuration data source:

 

 bool SetSSHKey(HostConnection oConn, string sshKey)

 {

         return oConn.setSSHKey(sshKey);

 }


© 2022 Inventu Corporation