Azure Add-AzureProvisioningConfig ssh 密钥或密钥对上传 [英] Azure Add-AzureProvisioningConfig ssh key or key pair upload

查看:40
本文介绍了Azure Add-AzureProvisioningConfig ssh 密钥或密钥对上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Azure Powershell commandlet,我想配置一个没有 SSH 密码而只有 SSH 密钥的新 Linux VM(在配置 CoreOS 时是必需的).将 Azure CLI 与命令行中指定的公钥文件一起使用时,一切正常.显然,这不适用于 Powershell commandlet Add-AzureProvisioningConfig.它需要两个可能的 SSH 密钥参数,但它们都是密钥对列表.正如 此处记录,参数 -SSHKeyPairs 指定了一个列表已在订阅中部署的 SSH 密钥对.我不知道如何在订阅中部署密钥对,也无法在任何地方找到它的文档.同样,-SSHPublicKeys 指定已在订阅中部署的 SSH 公钥列表.

Using Azure Powershell commandlets, I want to provision a new Linux VM with no SSH password and only SSH keys (necessary when provisioning CoreOS). When using the Azure CLI along with a public key file specified on the command line, everything works well. Apparently this is not available for the Powershell commandlet Add-AzureProvisioningConfig. It takes two possible SSH Key arguments, but they are both lists of key pairs. As documented here, the argument -SSHKeyPairs specifies a list of SSH key pairs already deployed in the subscription. I have no idea how to deploy key pairs in the subscription, nor can I find it documented anywhere. Likewise, -SSHPublicKeys specifies a list of SSH public keys already deployed in the subscription.

推荐答案

您可以使用 Openssl.exe 实用程序来生成证书.

You can use Openssl.exe utility to generate the certificate.

以下是此命令的示例:

openssl.exe req -x509 -nodes -days 365 -newkey rsa:2048 -keyout myPrivateKey.key -out myCert.pem

如何使用 SSH 配置 Linux 虚拟机的完整示例:

Complete example of how to provision a Linux virtual machine using an SSH:

$location = "West US"
$serviceName = "contosolinux1"
$vmName = "linuxvm1"
$size = "Small"
$adminUser = "[admin user name]"
$password = "[admin password]"
$imageFamily = "Ubuntu Server 14.10 DAILY"
$imageName = Get-AzureVMImage |
where { $_.ImageFamily -eq $imageFamily } |
sort PublishedDate -Descending |
select -ExpandProperty ImageName -First 1
$certPath = "$PSScriptRoot\MyCert.pem"
New-AzureService -ServiceName $serviceName `
-Location $location
$cert = Get-PfxCertificate -FilePath $certPath
Add-AzureCertificate -CertToDeploy $certPath `
-ServiceName $serviceName
$sshKey = New-AzureSSHKey -PublicKey -Fingerprint $cert.Thumbprint `
-Path "/home/$linuxUser/.ssh/authorized_keys"
New-AzureVMConfig -Name $vmName `
-InstanceSize $size `
-ImageName $imageName |
Add-AzureProvisioningConfig -Linux `
-AdminUsername $adminUser `
-Password $password `
-SSHPublicKeys $sshKey |
New-AzureVM -ServiceName $serviceName

来源:https://www.microsoftpressstore.com/store/exam-ref-70-533-implementing-microsoft-azure-infrastructure-9780735697065

这篇关于Azure Add-AzureProvisioningConfig ssh 密钥或密钥对上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆