2015-11-03 95 views
0

使用Azure Powershell命令行开关,我想配置一个没有SSH密码且只有SSH密钥(在配置CoreOS时必需)的新Linux VM。将Azure CLI与命令行中指定的公用密钥文件一起使用时,一切正常。显然,这不适用于Powershell命令行程序Add-AzureProvisioningConfig。它需要两个可能的SSH Key参数,但它们都是密钥对的列表。作为documented here,参数-SSHKeyPairs指定已在订阅中部署的SSH密钥对的列表。我不知道如何在订阅中部署密钥对,我也不能在任何地方找到它。同样,-SSHPublicKeys指定已在订阅中部署的SSH公钥列表。Azure Add-AzureProvisioningConfig ssh密钥或密钥对上传

回答

1

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

下面是这个命令的例子:

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

的完整示例如何使用SSH提供Linux虚拟机:

$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

+0

没有有机会尝试没有帐户密码。这就是我想要的(CoreOS需要)。 –