ALIYUN::ECS::SSHKeyPair類型用于創建SSH密鑰對或導入已有的SSH密鑰對。

語法

{
  "Type": "ALIYUN::ECS::SSHKeyPair",
  "Properties": {
    "ResourceGroupId": String,
    "KeyPairName": String,
    "PublicKeyBody": String,
    "Tags": List
  }
}

屬性

屬性名稱類型必須允許更新描述約束
ResourceGroupIdString實例所在的資源組ID。
KeyPairName String 密鑰對的名稱。 長度為2~128個字符。必須以英文字母或漢字開頭,不能以http://https://開頭??砂⑽淖帜?、漢字、數字、半角冒號(:)、下劃線(_)和短劃線(-)。
PublicKeyBody String 密鑰對的公鑰內容。 僅在導入密鑰對時需要指定該參數。
TagsList標簽。最多支持添加20個標簽。

更多信息,請參見Tags屬性

Tags語法

"Tags": [
  {
    "Key": String,
    "Value": String
  }
]  

Tags屬性

屬性名稱類型必須允許更新描述約束
KeyString標簽鍵。長度為1~128個字符,不能以aliyunacs:開頭,不能包含http://或者https://
ValueString標簽值。長度為0~128個字符,不能以aliyunacs:開頭,不能包含http://或者https://

返回值

Fn::GetAtt

  • KeyPairFingerPrint:密鑰對的指紋。根據RFC4716定義的公鑰指紋格式,采用MD5信息摘要算法。
  • PrivateKeyBody:密鑰對的私鑰。未加密的PEM編碼PKCS#8格式的RSA私鑰內容。只有在第一次創建完成后有唯一的機會獲取密鑰對的私鑰。如果是導入已有公鑰,則不會有私鑰信息。
  • KeyPairName:密鑰對名稱。

示例

  • YAML格式

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters: {}
    Resources:
      SSHKeyPair:
        Type: ALIYUN::ECS::SSHKeyPair
        Properties:
          KeyPairName:
            Fn::Sub: ess-${ALIYUN::StackId}
    Outputs:
      KeyPairFingerPrint:
        Description: 'The fingerprint of the key pair. The public key fingerprint format defined in RFC4716: MD5 message digest algorithm. '
        Value:
          Fn::GetAtt:
            - SSHKeyPair
            - KeyPairFingerPrint
      KeyPairName:
        Description: SSH Key pair name.
        Value:
          Fn::GetAtt:
            - SSHKeyPair
            - KeyPairName
      PrivateKeyBody:
        Description: 'The private key of the key pair. Content of the RSA private key in the PKCS#8 format of the unencrypted PEM encoding. Refer to: https://www.openssl.org/docs/apps/pkcs8.html.User only can get the private key one time when and only when SSH key pair is created.'
        Value:
          Fn::GetAtt:
            - SSHKeyPair
            - PrivateKeyBody
  • JSON格式

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Parameters": {
      },
      "Resources": {
        "SSHKeyPair": {
          "Type": "ALIYUN::ECS::SSHKeyPair",
          "Properties": {
            "KeyPairName": {
              "Fn::Sub": "ess-${ALIYUN::StackId}"
            }
          }
        }
      },
      "Outputs": {
        "KeyPairFingerPrint": {
          "Description": "The fingerprint of the key pair. The public key fingerprint format defined in RFC4716: MD5 message digest algorithm. ",
          "Value": {
            "Fn::GetAtt": [
              "SSHKeyPair",
              "KeyPairFingerPrint"
            ]
          }
        },
        "KeyPairName": {
          "Description": "SSH Key pair name.",
          "Value": {
            "Fn::GetAtt": [
              "SSHKeyPair",
              "KeyPairName"
            ]
          }
        },
        "PrivateKeyBody": {
          "Description": "The private key of the key pair. Content of the RSA private key in the PKCS#8 format of the unencrypted PEM encoding. Refer to: https://www.openssl.org/docs/apps/pkcs8.html.User only can get the private key one time when and only when SSH key pair is created.",
          "Value": {
            "Fn::GetAtt": [
              "SSHKeyPair",
              "PrivateKeyBody"
            ]
          }
        }
      }
    }

更多示例,請參見創建單個ECS實例、創建SSH密鑰對和綁定SSH密鑰和ECS實例的組合示例:JSON示例YAML示例