以非超级用户身份运行自定义脚本扩展名

问题描述 投票:1回答:1

我正在尝试在模板部署过程中运行自定义外壳脚本。我已按照此页面上的说明进行操作:https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-linux

自定义脚本扩展名可以正常工作,但是脚本始终以root身份运行。是否可以在模板部署时为其他用户运行它?

azure azure-resource-manager
1个回答
2
投票

看来这是不可能的:https://github.com/Azure/custom-script-extension-linux/issues/134

我这样做的动机是,我想在主目录中为新用户放置一个文件。因此,作为一种解决方法,由于脚本无论如何都以sudo身份运行,因此可以将文件简单地放在用户目录中:

{
    "type": "extensions",
    "apiVersion": "2017-03-30",
    "name": "config-app2",
    "location": "[resourceGroup().location]",
    "dependsOn": [
        "[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
    ],
    "tags": {
        "displayName": "config-app2"
    },
    "properties": {
        "publisher": "Microsoft.Azure.Extensions",
        "type": "CustomScript",
        "typeHandlerVersion": "2.0",
        "autoUpgradeMinorVersion": true,
        "settings": {
            "skipDos2Unix": false
        },
        "protectedSettings": {
            "commandToExecute": "[concat('curl -s \"https://s3.amazonaws.com/...\" -o',' ', '/home/',parameters('username'),'/...')]"
        }
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.