linux - 如何从 azure 自动化证书中获取公钥

标签 linux powershell azure ssl ssh

我需要从存储在 azure 门户上的证书获取 SSH 公钥,并且我已经在 azure 自动化上创建了工作流并将证书导入到 azure 门户。获得 SSH 公钥后,我必须使用此 SSH 公钥创建 Linux VM(从我的端准备好此脚本,无需添加 SSH key )。

最佳答案

根据我的理解,您的证书应该是 DER 编码的 X.509 证书,扩展名为 .cer

您可以使用以下 PowerShell 脚本从您的证书中获取公钥:

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

希望这对您有所帮助!

关于linux - 如何从 azure 自动化证书中获取公钥,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34655007/

相关文章:

bash - git !alias 可以在 bash 和 Powershell 中使用

powershell - 使用动态构造的排除模式数组,使用 Get-ChildItem -Exclude 过滤子文件夹

azure - 二头肌 : how to deploy resource conditionally only if it does not exists

.net - 使用 CI CD Azure DevOps 部署之前使 APP 脱机

linux - Elasticsearch安装错误: No such file or directory

linux - 无需重启 sshd 即可为授权用户添加 key

linux - vmsplice() 和 TCP

linux - 如果 TCP 服务器脱离网络,接受函数是否返回错误 (-1)

powershell - 将pscustomobject传递到Start-Job脚本 block 时,为什么脚本属性丢失?

azure - 如何查找 Azure 订阅配额