Todos os produtos
Search
Central de documentação

Resource Orchestration Service:ALIYUN::ENS::KeyPair

Última atualização: Jun 27, 2026

O recurso ALIYUN::ENS::KeyPair importa a chave pública de um par de chaves com criptografia RSA (Rivest-Shamir-Adleman).

Sintaxe

{
  "Type": "ALIYUN::ENS::KeyPair",
  "Properties": {
    "KeyPairName": String,
    "PublicKeyBody": String
  }
}

Propriedades

Propriedade

Tipo

Obrigatória

Editável

Descrição

Restrição

KeyPairName

String

Sim

Não

Nome do par de chaves.

O nome deve obedecer às seguintes regras:

  • Ter entre 2 e 128 caracteres.

  • Começar com uma letra, sem iniciar com http:// ou https://.

  • Conter letras, dígitos, dois-pontos (:), sublinhados (_) e hifens (-).

Especifique apenas um par de chaves.

PublicKeyBody

String

Não

Não

Chave pública do par de chaves.

Especifique apenas uma chave pública.

Valores de retorno

Fn::GetAtt

  • KeyPairFingerPrint: impressão digital do par de chaves. Usa o algoritmo MD5 (Message-Digest Algorithm 5) conforme o formato de impressão digital de chave pública definido na RFC 4716.

  • KeyPairName: nome do par de chaves.

  • PrivateKeyBody: chave pública do par de chaves.

Exemplos

Formato YAML

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  KeyPairName:
    Type: String
    Description:
      en: |-
        The name of the key pair. The name must conform to the following naming conventions:
        The name must be 2 to 128 characters in length, and can contain letters, digits, colons (:), underscores (_), and hyphens (-).
        It must start with a letter but cannot start with http:// or https://.
    Required: true
  PublicKeyBody:
    Type: String
    Description:
      en: SSH Public key. If PublicKeyBody is specified, existed public key body will be imported instead of creating new SSH key pair.
    Required: false
Resources:
  KeyPair:
    Type: ALIYUN::ENS::KeyPair
    Properties:
      KeyPairName:
        Ref: KeyPairName
      PublicKeyBody:
        Ref: PublicKeyBody
Outputs:
  KeyPairFingerPrint:
    Description: The fingerprint of the key pair. The message-digest algorithm 5 (MD5) is used based on the public key fingerprint format defined in RFC 4716. For more information, see RFC 4716.
    Value:
      Fn::GetAtt:
        - KeyPair
        - KeyPairFingerPrint
  KeyPairName:
    Description: SSH Key pair name.
    Value:
      Fn::GetAtt:
        - KeyPair
        - KeyPairName
  PrivateKeyBody:
    Description: The private key of the key pair. The private key is encoded with PEM in the PKCS#8 format.
    Value:
      Fn::GetAtt:
        - KeyPair
        - PrivateKeyBody

Formato JSON

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "KeyPairName": {
      "Type": "String",
      "Description": {
        "en": "The name of the key pair. The name must conform to the following naming conventions:\nThe name must be 2 to 128 characters in length, and can contain letters, digits, colons (:), underscores (_), and hyphens (-).\nIt must start with a letter but cannot start with http:// or https://."
      },
      "Required": true
    },
    "PublicKeyBody": {
      "Type": "String",
      "Description": {
        "en": "SSH Public key. If PublicKeyBody is specified, existed public key body will be imported instead of creating new SSH key pair."
      },
      "Required": false
    }
  },
  "Resources": {
    "KeyPair": {
      "Type": "ALIYUN::ENS::KeyPair",
      "Properties": {
        "KeyPairName": {
          "Ref": "KeyPairName"
        },
        "PublicKeyBody": {
          "Ref": "PublicKeyBody"
        }
      }
    }
  },
  "Outputs": {
    "KeyPairFingerPrint": {
      "Description": "The fingerprint of the key pair. The message-digest algorithm 5 (MD5) is used based on the public key fingerprint format defined in RFC 4716. For more information, see RFC 4716.",
      "Value": {
        "Fn::GetAtt": [
          "KeyPair",
          "KeyPairFingerPrint"
        ]
      }
    },
    "KeyPairName": {
      "Description": "SSH Key pair name.",
      "Value": {
        "Fn::GetAtt": [
          "KeyPair",
          "KeyPairName"
        ]
      }
    },
    "PrivateKeyBody": {
      "Description": "The private key of the key pair. The private key is encoded with PEM in the PKCS#8 format.",
      "Value": {
        "Fn::GetAtt": [
          "KeyPair",
          "PrivateKeyBody"
        ]
      }
    }
  }
}