All Products
Search
Document Center

Elastic Compute Service:DescribeKeyPairs

Last Updated:Jun 18, 2026

Queries one or more key pairs.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ecs:DescribeKeyPairs

get

KeyPair

acs:ecs:{#regionId}:{#accountId}:keypair/{#keypairName}

KeyPair

acs:ecs:{#regionId}:{#accountId}:keypair/*

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID of the key pairs. You can call DescribeRegions to query the most recent region list.

cn-hangzhou

KeyPairName

string

No

The name of the key pair. You can use regular expressions for fuzzy search, with the asterisk (*) to match child table expressions. Examples:

  • *SshKey: searches for key pair names that end with SshKey, including SshKey.

  • SshKey*: searches for key pair names that start with SshKey, including SshKey.

  • *SshKey*: searches for key pair names that contain SshKey, including SshKey.

  • SshKey: exact match of SshKey.

*SshKey*

KeyPairFingerPrint

string

No

The fingerprint of the key pair. The fingerprint uses the message-digest algorithm 5 (MD5) based on the public key fingerprint format defined in RFC 4716. For more information, see RFC 4716.

ABC1234567

PageNumber

integer

No

The page number of the key pair list. Minimum value: 1.

Default value: 1.

1

PageSize

integer

No

The number of entries per page in paging queries. Settings: Maximum value: 50.

Default value: 10.

10

IncludePublicKey

boolean

No

Specifies whether to include PublicKey in the response. Default value: false.

false

ResourceGroupId

string

No

The ID of the resource group to which the key pairs belong. When you use this parameter to filter resources, the resource count cannot exceed 1000.

Note

Filtering by the default resource group is not supported.

rg-amnhr7u7c7hj****

Tag

array<object>

No

The tags.

object

No

Key

string

No

The tag key of the key pair. Valid values of N: 1 to 20.

If you use a single tag to filter resources, the resource count with the specified tag cannot exceed 1000. If you use multiple tags to filter resources, the resource count of resources that are attached with all specified tags cannot exceed 1000. If the resource count exceeds 1000, call the ListTagResources operation to query resources.

TestKey

Value

string

No

The tag value of the key pair. Valid values of N: 1 to 20.

TestValue

Response elements

Element

Type

Description

Example

object

PageSize

integer

The number of entries per page.

10

RequestId

string

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

PageNumber

integer

The current page number.

1

TotalCount

integer

The total number of key pairs.

1

KeyPairs

object

KeyPair

array<object>

The key pair information.

array<object>

CreationTime

string

The time when the key pair was created.

2023-09-04T08:33Z

KeyPairName

string

The name of the key pair.

testKeyPairName

KeyPairFingerPrint

string

The fingerprint of the key pair.

ABC1234567

ResourceGroupId

string

The ID of the resource group.

rg-amnhr7u7c7hj****

PublicKey

string

The content of the public key.

ssh-rsa****

Tags

object

Tag

array<object>

The tags of the key pair.

object

TagValue

string

The tag value of the key pair.

TestValue

TagKey

string

The tag key of the key pair.

TestKey

Examples

Success response

JSON format

{
  "PageSize": 10,
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E",
  "PageNumber": 1,
  "TotalCount": 1,
  "KeyPairs": {
    "KeyPair": [
      {
        "CreationTime": "2023-09-04T08:33Z",
        "KeyPairName": "testKeyPairName",
        "KeyPairFingerPrint": "ABC1234567",
        "ResourceGroupId": "rg-amnhr7u7c7hj****",
        "PublicKey": "ssh-rsa****",
        "Tags": {
          "Tag": [
            {
              "TagValue": "TestValue",
              "TagKey": "TestKey"
            }
          ]
        }
      }
    ]
  }
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.