MongoDB副本集-参数linuxConfiguration.ssh.publicKeys.keyData的值无效

fdx2calv  于 2023-04-11  发布在  Go
关注(0)|答案(2)|浏览(105)

这与此处定义的MongoDB副本集的Azure部署模板mongodb-replica-set-centos有关。
当我运行推荐的部署命令来部署副本集时,即

az group create --name <resource-group-name> --location <resource-group-location> # Use this command when you need to create a new resource group for your deployment.
az deployment group create --resource-group <my-resource-group> --template-uri https://raw.githubusercontent.com/migr8/AzureDeploymentTemplates/main/mongo/mongodb-replica-set-centos/azuredeploy.json

其中资源组已设置。我收到以下错误:

{
  "status": "Failed",
  "error": {
    "code": "DeploymentFailed",
    "message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.",
    "details": [
      {
        "code": "Conflict",
        "message": "{\r\n  \"status\": \"Failed\",\r\n  \"error\": {\r\n    \"code\": \"ResourceDeploymentFailure\",\r\n    \"message\": \"The resource operation completed with terminal provisioning state 'Failed'.\",\r\n    \"details\": [\r\n      {\r\n        \"code\": \"DeploymentFailed\",\r\n        \"message\": \"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.\",\r\n        \"details\": [\r\n          {\r\n            \"code\": \"BadRequest\",\r\n  \"message\": \"{\\r\\n  \\\"error\\\": {\\r\\n    \\\"code\\\": \\\"InvalidParameter\\\",\\r\\n    \\\"message\\\": \\\"The value of parameter linuxConfiguration.ssh.publicKeys.keyData is invalid.\\\",\\r\\n    \\\"target\\\": \\\"linuxConfiguration.ssh.publicKeys.keyData\\\"\\r\\n  }\\r\\n}\"\r\n          }\r\n        ]\r\n      }\r\n    ]\r\n  }\r\n}"
      },
      {
        "code": "Conflict",
        "message": "{\r\n  \"status\": \"Failed\",\r\n  \"error\": {\r\n    \"code\": \"ResourceDeploymentFailure\",\r\n    \"message\": \"The resource operation completed with terminal provisioning state 'Failed'.\",\r\n    \"details\": [\r\n      {\r\n        \"code\": \"DeploymentFailed\",\r\n        \"message\": \"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.\",\r\n        \"details\": [\r\n          {\r\n            \"code\": \"BadRequest\",\r\n            \"message\": \"{\\r\\n  \\\"error\\\": {\\r\\n    \\\"code\\\": \\\"InvalidParameter\\\",\\r\\n    \\\"message\\\": \\\"The value of parameter linuxConfiguration.ssh.publicKeys.keyData is invalid.\\\",\\r\\n    \\\"target\\\": \\\"linuxConfiguration.ssh.publicKeys.keyData\\\"\\r\\n  }\\r\\n}\"\r\n          }\r\n        ]\r\n      }\r\n    ]\r\n  }\r\n}"
      }
    ]
  }
}

问题字段位于primary-resources.json和secondary-resources.json中,似乎是

"variables": {
        "subnetRef": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('subnet').vnet, parameters('subnet').name)]",
        "securityGroupName": "[concat(parameters('namespace'), parameters('vmbasename'), 'nsg')]",
        "linuxConfiguration": {
            "disablePasswordAuthentication": true,
            "ssh": {
                "publicKeys": [
                    {
                        "path": "[concat('/home/', parameters('adminUsername'), '/.ssh/authorized_keys')]",
                        "keyData": "[parameters('adminPasswordOrKey')]"
                    }
                ]
            }
        }
    },

并与变量adminPasswordOrKey关联。我尝试将其更改为标准密码和不同位深度的SSH密钥,没有运气......
我该怎么解决这个问题?

复制步骤

1.在存在资源组的位置运行az group create --name <resource-group-name> --location <resource-group-location>
1.运行az deployment group create --resource-group <my-resource-group> --template-uri https://raw.githubusercontent.com/migr8/AzureDeploymentTemplates/main/mongo/mongodb-replica-set-centos/azuredeploy.json并逐步完成提示
1.输入相关信息。

进一步调查

我刚刚看到这个答案(https://stackoverflow.com/a/60860498/626442)明确地说
注意:请注意,由于Azure的限制,唯一允许的路径是/home//.ssh/authorized_keys。
我已经改变了这条道路的价值,没有欢乐,同样的错误。

nfzehxib

nfzehxib1#

您忘记在az deployment group create .... --parameters azuredeploy.parameters.json中传递参数。您可以下载azuredeploy.parameters.json并根据需要更改值。有关详细信息,请参阅https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/template-tutorial-use-parameter-file?tabs=azure-cli#deploy-template。
具体来说,问题中的错误抱怨adminUsername参数为空。请记住,此用户名也用于主目录路径中,因此请限制自己使用小写ASCII a-z,数字,下划线。没有空格,没有特殊字符,没有utf。
与错误无关,但要注意这些亡灵 Mage 使用mongo3.2,这是4年前埋葬:https://www.mongodb.com/support-policy/lifecycles。考虑到他们向互联网开放,如果你实际部署它,你可能会遇到更多的问题。

更新

我使用的参数示例:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "adminUsername": {
      "value": "yellow"
    },
    "mongoAdminUsername": {
      "value": "phrase"
    },
    "mongoAdminPassword": {
      "value": "settle#SING"
    },
    "secondaryNodeCount": {
      "value": 2
    },
    "sizeOfDataDiskInGB": {
      "value": 2
    },
    "dnsNamePrefix": {
      "value": "written"
    },
    "centOsVersion": {
      "value": "7.7"
    },
    "primaryNodeVmSize": {
      "value": "Standard_D1_v2"
    },
    "secondaryNodeVmSize": {
      "value": "Standard_D1_v2"
    },
    "zabbixServerIPAddress": {
      "value": "Null"
    },
    "adminPasswordOrKey": {
      "value": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDdNRTU0XF3xazhhDmwXXWGG7wp4AaQC1r89K7sZFRXp9VSUtydV59DHr67mV5/0DWI5Co1yWK713QJ00BPlBIHNMNLuoBBq8IkOx8fBZF1g9YFm5Zy4ay+CF4WgDITAsyxhKvUWL6jwG5M3XIdVYm49K+EFOCWSSaNtCk8tHhi3v6/5HFkwc2r0UL/WWWbbt5AmpJ8QOCDk/x+XcgCjP9vE5jYYGsFz9F6V1FdOpjVfDwi13Ibivj/w2wOZh2lQGskC+qDjd2upK13+RfWYHY3rr+ulNRPckHRhOqmZ2vlUapO4T0X9mM6ugSh1FprLP5nHdVCUls2yw4BAcSoM9NMiyafE56Xkp9h3bTAfx5Ufpe5mjwQp+j15np1pVpwDaEgk7ZeaPoZPhbalpvZGyg9KiKfs9+KUYHfGklIOHKJ3RUoPE286rg1U4LGswil5RARRSf86kBBHXaIPxy1X0N6QryeWhk0aM6LWEdl7mVbQksa7ilANnsaVMl7FSdY/Cc="
    }
  }
}

危险:会使用可公开访问的凭证部署可公开访问的mongodb副本集,请在测试/调试满意后尽快删除资源

以下是门户上的部署:

ssm49v7z

ssm49v7z2#

如果您使用的是Ed25519密钥类型,请注意Microsoft Azure当前不支持虚拟机(VM)的Ed25519 SSH密钥。Azure中VM身份验证支持的SSH密钥类型是RSA和DSA密钥类型。
https://learn.microsoft.com/en-us/troubleshoot/azure/virtual-machines/ed25519-ssh-keys

相关问题