Ssh Public Keys - Create
Creates a new SSH public key resource.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/sshPublicKeys/{sshPublicKeyName}?api-version=2024-03-01
URI Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
|
resource
|
path | True |
string |
The name of the resource group. |
|
ssh
|
path | True |
string |
The name of the SSH public key. |
|
subscription
|
path | True |
string |
Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. |
|
api-version
|
query | True |
string |
Client Api Version. |
Request Body
| Name | Required | Type | Description |
|---|---|---|---|
| location | True |
string |
Resource location |
| properties.publicKey |
string |
SSH public key used to authenticate to a virtual machine through ssh. If this property is not initially provided when the resource is created, the publicKey property will be populated when generateKeyPair is called. If the public key is provided upon resource creation, the provided public key needs to be at least 2048-bit and in ssh-rsa format. |
|
| tags |
object |
Resource tags |
Responses
| Name | Type | Description |
|---|---|---|
| 200 OK |
OK |
|
| 201 Created |
Created |
|
| Other Status Codes |
Error response describing why the operation failed. |
Security
azure_auth
Azure Active Directory OAuth2 Flow
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
| Name | Description |
|---|---|
| user_impersonation | impersonate your user account |
Examples
Create a new SSH public key resource.
Sample request
PUT https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/sshPublicKeys/mySshPublicKeyName?api-version=2024-03-01
{
"location": "westus",
"properties": {
"publicKey": "{ssh-rsa public key}"
}
}
Sample response
{
"name": "mySshPublicKeyName",
"location": "westus",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/sshPublicKeys/mySshPublicKeyName",
"properties": {
"publicKey": "{ssh-rsa public key}"
}
}
{
"name": "mySshPublicKeyName",
"location": "westus",
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/sshPublicKeys/mySshPublicKeyName",
"properties": {
"publicKey": "{ssh-rsa public key}"
}
}
Definitions
| Name | Description |
|---|---|
|
Api |
Api error. |
|
Api |
Api error base. |
|
Cloud |
An error response from the Compute service. |
|
Inner |
Inner error details. |
|
Ssh |
Specifies information about the SSH public key. |
ApiError
Api error.
| Name | Type | Description |
|---|---|---|
| code |
string |
The error code. |
| details |
The Api error details |
|
| innererror |
The Api inner error |
|
| message |
string |
The error message. |
| target |
string |
The target of the particular error. |
ApiErrorBase
Api error base.
| Name | Type | Description |
|---|---|---|
| code |
string |
The error code. |
| message |
string |
The error message. |
| target |
string |
The target of the particular error. |
CloudError
An error response from the Compute service.
| Name | Type | Description |
|---|---|---|
| error |
Api error. |
InnerError
Inner error details.
| Name | Type | Description |
|---|---|---|
| errordetail |
string |
The internal error message or exception dump. |
| exceptiontype |
string |
The exception type. |
SshPublicKeyResource
Specifies information about the SSH public key.
| Name | Type | Description |
|---|---|---|
| id |
string |
Resource Id |
| location |
string |
Resource location |
| name |
string |
Resource name |
| properties.publicKey |
string |
SSH public key used to authenticate to a virtual machine through ssh. If this property is not initially provided when the resource is created, the publicKey property will be populated when generateKeyPair is called. If the public key is provided upon resource creation, the provided public key needs to be at least 2048-bit and in ssh-rsa format. |
| tags |
object |
Resource tags |
| type |
string |
Resource type |