Can I use an SSH identity file for authentication?
You can set the SSHCert property and Public Key authentication to use an identity file for authentication.
Date Entered: 12/01/2014 Last Updated: 12/01/2014
To do so, you'll need to create, or already have, the public and private key pair. You'll need to make sure that the public key is included on the server. From there you would use code similar to the following to authenticate, using the private key file:
Sshclient client = new Sshclient();
client.SSHAuthMode = SshclientSSHAuthModes.amPublicKey;
client.SSHCert = new Certificate();
client.SSHCert.StoreType = CertStoreTypes.cstPEMKeyFile;
client.SSHCert.Store = @"C:\Users\Joe\user-ca-key.pem";
client.SSHCert.StorePassword = "keyPassword";
client.SSHCert.Subject = "*";
client.SSHUser = "root";
client.SSHLogon([serverIP], [serverPort]);
//perform actions here
client.SSHLogoff();
We appreciate your feedback. If you have any questions, comments, or suggestions about this entry please contact our support team at kb@nsoftware.com.