---
external help file: Microsoft.Azure.Commands.Compute.dll-Help.xml
online version: 
schema: 2.0.0
ms.assetid: 44058EB2-8404-4AAA-A590-B147A5723192
---
# Add-AzureVMSshPublicKey
## SYNOPSIS
Adds the public keys for SSH for a virtual machine.
## SYNTAX
```
Add-AzureVMSshPublicKey [-VM] <PSVirtualMachine> [[-KeyData] <String>] [[-Path] <String>]
 [-Profile <AzureProfile>] [<CommonParameters>]
```
## DESCRIPTION
The **Add-AzureVMSshPublicKey** cmdlet adds the public keys that you can use to connect to a virtual machine over Secure Shell (SSH).
## EXAMPLES
### Example 1: Add a public key to a virtual machine
```
PS C:\>$VirtualMachine = Get-AzureVM -ResourceGroupName "ResourceGroup11" -Name "VirtualMachine07"
PS C:\> $VirtualMachine = Add-AzureVMSshPublicKey -VM $VirtualMachine -KeyData "<KEY>" -Path "/home/admin/.ssh/authorized_keys"
```
The first command gets the virtual machine named VirtualMachine07 by using the **Get-AzureVM** 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.
## PARAMETERS
### -KeyData
Specifies a base 64 encoding of a public key.
You can connect to a virtual machine by using SSH by using the key that this parameter specifies.
```yaml
Type: String
Parameter Sets: (All)
Aliases: 
Required: False
Position: 2
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```
### -Path
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.
```yaml
Type: String
Parameter Sets: (All)
Aliases: 
Required: False
Position: 3
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```
### -Profile
Specifies the Azure profile from which this cmdlet reads.
If you do not specify a profile, this cmdlet reads from the local default profile.
```yaml
Type: AzureProfile
Parameter Sets: (All)
Aliases: 
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -VM
Specifies the virtual machine object that this cmdlet modifies.
To obtain a virtual machine object, use the **Get-AzureVM** cmdlet.
Create a virtual machine object by using the **New-AzureVMConfig** cmdlet.
```yaml
Type: PSVirtualMachine
Parameter Sets: (All)
Aliases: VMProfile
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
## OUTPUTS
## NOTES
## RELATED LINKS
[Get-AzureVM](./Get-AzureVM.md)