Discuss this help topic in SecureBlackbox Forum
Save an SSH key to a file
After you've generated a key (or loaded it from somewhere) you might wish to save it to some media. The public and private part of the key should be saved separately. It is a good idea to use password for protecting private keys.
Keys are saved with SavePublicKey() and SavePrivateKey() methods. Depending on your requirements (e.g. the need to be compatible to some third-party software), you might need to set a particular format to use for the key. You can set the exact format via the KeyFormat property. Some other properties, such as Comment, Subject or KeyProtectionAlgorithm, might also need to be set before saving the key.
C#:
key.KeyFormat = TSBSSHKeyFormat.kfIETF;
key.Subject = "ssh.host.com";
key.Comment = "Generated by MySSHTool";
int rpub = key.SavePublicKey(@"C:\SSH\key.pub");
if (key.IsPrivate)
{
int rpriv = key.SavePrivateKey(@"C:\SSH\key.priv", "password");
}
All SaveXXX() methods return a result code. The code of 0 indicates successful operation, while non-zero values indicate an error. Error constants (0x0dXY) are defined in SBSSHKeyStorage namespace.