title: Convert DER encoded certificate to ssh-rsa public key
body: <p>I am working on a project to automate extracting a public key DER encoded certificate from a users smart card, and convert it to ssh-rsa public key form. The ssh-rsa public key would then be published as a user attribute in AD. From there puppet would grab the ssh public key using an ldap query and place it in the authorized_keys file for the user in question.</p>
  
  <p>The problem I am running into is that in Windows there doesn't seem to be a way to make the conversion from DER encoded .cer file to a ssh-rsa key.  If the certificate is moved to the users home directory then it is possible to run:</p>
  
  <pre><code>openssl x509 -inform pem -in username.cer -noout -pubkey &gt; username.pub
  </code></pre>
  
  <p>Then ssh-keygen can create the ssh-rsa public key using:</p>
  
  <pre><code>ssh-keygen -f username.pub -i -m PKCS8
  </code></pre>
  
  <p>So does anyone know of a way for windows to make this conversion? If you need more information please let me know.</p>