rgg
rgg

Reputation: 35

how to get public key from certificate on azure automation

I need to get SSH public key from the certificate which is store on azure portal and I have created workflow on azure automation and import the certificate to azure portal. Once we get the SSH public key, I have to create linux VM with this SSH public key(Ready this script from myend without add SSH key).

Upvotes: 0

Views: 1225

Answers (1)

juvchan
juvchan

Reputation: 6255

Based on my understanding, your certificate should be DER encoded X.509 certificate with .cer extension.

You can get the public key from your certificate using the PowerShell script below:

$certPath = "testcert.cer"
$x509Cert = [System.Security.Cryptography.X509Certificates.X509Certificate2]::CreateFromCertFile($certPath)
$pk = $x509Cert.GetPublicKeyString()

Hope this helps!

Upvotes: 1

Related Questions