< Back

Add-AzureRmVMSshPublicKey

Tue Jan 29, 2019 9:37 pm

NAME Add-AzureRmVMSshPublicKey



SYNOPSIS

Adds the public keys for SSH for a virtual machine.





SYNTAX

Add-AzureRmVMSshPublicKey [-VM] <PSVirtualMachine> [[-KeyData] <String>] [[-Path] <String>] [-DefaultProfile <IAzureContextContainer>]

[<CommonParameters>]





DESCRIPTION

The Add-AzureRmVMSshPublicKey cmdlet adds the public keys that you can use to connect to a virtual machine over Secure Shell (SSH).





PARAMETERS

-DefaultProfile <IAzureContextContainer>

The credentials, account, tenant, and subscription used for communication with azure.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-KeyData <String>

Specifies a base 64 encoding of a public key. You can connect to a virtual machine by using SSH or by using the key that this parameter

specifies.



Required? false

Position? 1

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-Path <String>

Specifies the full path of a file, on the virtual machine, where this cmdlet stores the SSH public key. If the file already exists, this

cmdlet appends the key to the file.



Required? false

Position? 2

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-VM <PSVirtualMachine>

Specifies the virtual machine object that this cmdlet modifies. To obtain a virtual machine object, use the Get-AzureRmVM

(./Get-AzureRmVM.md)cmdlet. You can use the New-AzureRmVMConfig (./New-AzureRmVMConfig.md)cmdlet to create a virtual machine object.



Required? true

Position? 0

Default value None

Accept pipeline input? True (ByPropertyName, ByValue)

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 (http://go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

PSVirtualMachine

Parameter 'VM' accepts value of type 'PSVirtualMachine' from the pipeline





OUTPUTS

Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine







NOTES









Example 1: Add a public key to a virtual machine



PS C:\\> $VirtualMachine = Get-AzureRmVM -ResourceGroupName "ResourceGroup11" -Name "VirtualMachine07"

PS C:\\> $VirtualMachine = Add-AzureRmVMSshPublicKey -VM $VirtualMachine -KeyData

"MIIDszCCApugAwIBAgIJALBV9YJCF/tAMA0GCSq12Ib3DQEB21QUAMEUxCzAJBgNV" -Path "/home/admin/.ssh/authorized_keys"



The first command gets the virtual machine named VirtualMachine07 by using the Get-AzureRmVM cmdlet. The command stores the virtual machine in the

$VirtualMachine variable.



The second command adds the public key to the location on VirtualMachine07 that the Path parameter specifies.







RELATED LINKS

Online Version: https://docs.microsoft.com/en-us/powers ... hpublickey

Get-AzureRmVmssDiskEncryption

New-AzureRmVMConfig