共用方式為


New-AzureSSHKey

建立 SSH 金鑰物件,將現有的憑證插入新的 Linux 型 Azure 虛擬機中。

注意

本文件中參考的 Cmdlet 用於管理使用 Azure Service Manager(ASM) API 的舊版 Azure 資源。 建立新的資源時,不建議使用此舊版 PowerShell 模組,因為 ASM 已排定淘汰。 如需詳細資訊,請參閱 Azure Service Manager 淘汰

Az PowerShell 模組是使用 PowerShell 管理 Azure Resource Manager (ARM) 資源的建議 PowerShell 模組。

語法

New-AzureSSHKey
   [-KeyPair]
   [-Fingerprint] <String>
   [-Path] <String>
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   [<CommonParameters>]
New-AzureSSHKey
   [-PublicKey]
   [-Fingerprint] <String>
   [-Path] <String>
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   [<CommonParameters>]

Description

New-AzureSSHKey Cmdlet 會為已新增至 Azure 的憑證建立 SSH 密鑰物件。 接著,使用 New-AzureVM 建立新虛擬機的組態物件時,或是使用 New-AzureQuickVM 建立新的虛擬機時,可以使用 New-AzureProvisioningConfig 使用此 SSH Key 物件。 當包含在虛擬機建立腳本中時,這會將指定的SSH 公鑰或金鑰組新增至新的虛擬機。

範例

範例 1:建立憑證設定物件

PS C:\> $myLxCert = New-AzureSSHKey -Fingerprint "D7BECD4D63EBAF86023BB4F1A5FBF5C2C924902A" -Path "/home/username/.ssh/authorized_keys"

此命令會建立現有憑證的憑證設定物件,然後將物件儲存在變數中以供日後使用。

範例 2:將憑證新增至服務

PS C:\> Add-AzureCertificate -ServiceName "MySvc" -CertToDeploy "C:\temp\MyLxCert.cer"
$myLxCert = New-AzureSSHKey ?Fingerprint "D7BECD4D63EBAF86023BB4F1A5FBF5C2C924902A" -Path "/home/username/.ssh/authorized_keys"
New-AzureVMConfig -Name "MyVM2" -InstanceSize Small -ImageName $LxImage `
          | Add-AzureProvisioningConfig -Linux -LinuxUser $lxUser -SSHPublicKeys $myLxCert -Password 'pass@word1' `
          | New-AzureVM -ServiceName "MySvc"

此命令會將憑證新增至 Azure 服務,然後建立使用憑證的新 Linux 虛擬機。

參數

-Fingerprint

指定憑證的指紋。

類型:String
Position:1
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-InformationAction

指定此 Cmdlet 如何回應資訊事件。

此參數可接受的值為:

  • 繼續
  • 忽略
  • 詢問
  • SilentlyContinue
  • 停止
  • 暫止
類型:ActionPreference
別名:infa
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-InformationVariable

指定資訊變數。

類型:String
別名:iv
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-KeyPair

指定此 Cmdlet 會建立 物件,以便將 SSH 金鑰組插入新的虛擬機組態。

類型:SwitchParameter
Position:0
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-Path

指定儲存 SSH 公鑰或金鑰組的路徑。

類型:String
Position:2
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False

-PublicKey

指定此 Cmdlet 會建立 物件,以便將 SSH 公鑰插入新的虛擬機組態中。

類型:SwitchParameter
Position:0
預設值:None
必要:True
接受管線輸入:False
接受萬用字元:False