New-AzureSSHKey

Creates a SSH Key object to insert an existing certificate into a new Linux-based Azure virtual machines.

Note

The cmdlets referenced in this documentation are for managing legacy Azure resources that use Azure Service Manager (ASM) APIs. This legacy PowerShell module isn't recommended when creating new resources since ASM is scheduled for retirement. For more information, see Azure Service Manager retirement.

The Az PowerShell module is the recommended PowerShell module for managing Azure Resource Manager (ARM) resources with PowerShell.

Syntax

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

The New-AzureSSHKey cmdlet creates an SSH Key object for a certificate that has already been added to Azure. This SSH Key object can then be used by New-AzureProvisioningConfig when creating the configuration object for a new virtual machine using New-AzureVM, or when creating a new virtual machine with New-AzureQuickVM. When included as part of a virtual machine creation script, this adds the specified SSH Public Key or Key Pair to the new virtual machine.

Examples

Example 1: Create a certificate setting object

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

This command creates a certificate setting object for an existing certificate and then stores the object in a variable for later use.

Example 2: Add a certificate to a service

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"

This command adds a certificate to an Azure service, and then creates a new Linux virtual machine that uses the certificate.

Parameters

-Fingerprint

Specifies the fingerprint of the certificate.

Type:String
Position:1
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-InformationAction

Specifies how this cmdlet responds to an information event.

The acceptable values for this parameter are:

  • Continue
  • Ignore
  • Inquire
  • SilentlyContinue
  • Stop
  • Suspend
Type:ActionPreference
Aliases:infa
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-InformationVariable

Specifies an information variable.

Type:String
Aliases:iv
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-KeyPair

Specifies that this cmdlet creates an object for inserting an SSH Key Pair into the new virtual machine configuration.

Type:SwitchParameter
Position:0
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Path

Specifies the path to store the SSH Public Key or Key Pair.

Type:String
Position:2
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-PublicKey

Specifies that this cmdlet creates an object for inserting an SSH Public Key into the new virtual machine configuration.

Type:SwitchParameter
Position:0
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False