Update: This feature has been added to Rebex SFTP 2012 R2. Please check out the other answer for more information.
In the current version of Rebex SFTP, this is only possible if the certificate's private key can be exported. In that case, the following code can be used:
X509Certificate2 cert = ...;
// get certificate's private key RSA CSP
RSACryptoServiceProvider rsa = (RSACryptoServiceProvider)cert.PrivateKey;
// export parameters, including the private ones
RSAParameters parameters = rsa.ExportParameters(true);
// create a SSH key from the exported parameters
SshPrivateKey key = SshPrivateKey.CreateFrom(parameters);
However, the exportable parameters requirement is only due to missing API. We could easily add a method that only takes
X509Certificate2.PrivateKey on input and creates a fully working SshPrivateKey based on that, regardless the exportable status. If you can afford to wait until next week, we can add this feature straight away and send you a beta to try. Please let me know if you are interested.