< Back

New-AzureSSHKey

Wed Jan 30, 2019 5:49 pm

NAME New-AzureSSHKey



SYNOPSIS

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





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.





PARAMETERS

-KeyPair [<SwitchParameter>]

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



Required? true

Position? 0

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-Fingerprint <String>

Specifies the fingerprint of the certificate.



Required? true

Position? 1

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Path <String>

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



Required? true

Position? 2

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-InformationAction <ActionPreference>





Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-InformationVariable <String>





Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-PublicKey [<SwitchParameter>]

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



Required? true

Position? 0

Default value False

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES









-------------------------- Example 1: Create a certificate setting object --------------------------



PS C:\\>$myLxCert = New-AzureSSHKey -Fingerprint $fingerprint -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 $fingerprint -Path "/home/username/.ssh/authorized_keys"

New-AzureVMConfig -Name "MyVM2" -InstanceSize Small -ImageName $LxImage `

| Add-AzureProvisioningConfig -Linux -LinuxUser $lxUser -SSHPublicKeys $myLxCert -Password 'password' `

| 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.



RELATED LINKS

Add-AzureProvisioningConfig

New-AzureVMConfig

New-AzureVM

New-AzureQuickVM