[英]Securing Credentials properly in DSC using Azure Automation
您将如何继续保护在 Azure 自动化中正确使用凭据的 DSC 配置?
例如:
configuration MyServer {
param(
[Parameter(Mandatory=$true)][PSCredential]$MyCredential
);
# Some configuration using credentials
}
通常我会在每个节点上设置一个公钥和一个适当的证书,并在编译配置文档时将 CertificateFile 和 Thumbprint 传递给 ConfigurationData。
在 Azure 自动化中,我找不到任何好的解决方案。
文档说 Azure 自动化由它自己加密整个 MOF: https ://azure.microsoft.com/en-us/documentation/articles/automation-certificates/ 并且文章指定使用 PSAllowPlainTextCredentials。
然后,当您将节点注册到其拉取服务器并拉取其配置时,只要您具有本地管理员/或对 temp 的读取访问权限,就可以在下拉/更新后以纯文本形式读出密码。 从安全的角度来看,这并不好。
我想要的是,理想情况下是将这样的公钥/证书上传到 Azure 自动化凭据,并在开始编译作业时将其用作 ConfigurationData 的一部分。
但是今天,“CertificateFile”需要一个路径而不是一个 AutomationCertificate,所以我看不到使用 Azure 自动化中存在的任何公钥启动编译作业的方法。 在运行作业时,我看不到任何引用我的资产证书的方式。
在 Azure 自动化的当前状态下这是否可行,以及他们使用 DSC/pull 使用资产存储 din Azure 自动化或 Azure Key Vault 正确保护它的方式有什么想法吗?
您应该创建一个 Azure 自动化凭据并在配置中引用它,如下所示:
# Compile mof
$ConfigurationData = @{
AllNodes = @(
@{
NodeName = $nodeName
PSDscAllowPlainTextPassword = $true
}
)
}
$Parameters = @{
"nodeName" = $nodeName
"credential" = $credName ##### Notice this is only the name on Azure Automation Credential Asset, Azure Automation will securely pull those and use in the compilation
}
Start-AzureRmAutomationDscCompilationJob -ResourceGroupName $ResourceGroupName -AutomationAccountName $AutomationAccountName `
-ConfigurationName $configurationName -Parameters $Parameters -ConfigurationData $ConfigurationData
您不必担心PSDscAllowPlainTextPassword
因为 Azure 自动化确实为您加密了所有PSDscAllowPlainTextPassword
内容,只是 DSC 不知道这一点(因此您必须将其提供给 DSC 引擎)。
在 DSC 中,您应该具有以下内容:
Configuration name
{
Param (
[Parameter(Mandatory)][ValidateNotNullOrEmpty()][String]$nodeName,
[Parameter(Mandatory)][ValidateNotNullOrEmpty()][pscredential]$credential
)
Import-DscResource -Module modules
Node $nodeName {DOSTUFF}
}
将凭据从 Azure 自动化传递到 DSC 文件的正确方法是使用 Azure 自动化凭据。
然后在 DSC 文件中使用命令 Get-AutomationPSCredential
示例:
Configuration BaseDSC
{
Import-DscResource -ModuleName xActiveDirectory
Import-DscResource -ModuleName PSDesiredStateConfiguration
Import-DscResource -ModuleName XNetworking
$Credential = Get-AutomationPSCredential -Name "CredentialName"
Node $AllNodes.Nodename
{ ...
凭据以加密方式存储在 Azure 自动化中,并在运行编译作业时放入 Azure 自动化中的加密 MOF 文件中。
此外,密码可以在 Azure 自动化中更新,然后通过重新编译在 MOF 中更新。
无法从 Azure 以明文形式检索密码。
使用安全凭证并创建用户到 Windows 服务器并使用 dsc 添加到管理员组:
**解决方案(PowerShell DSC)**
首先:在自动化帐户表单中创建凭据 azure 门户或使用任何 azure 模块主页>资源组> ...>自动化帐户>凭据
Configuration user_windows_user
{
param
(
[Parameter()][string]$username,
[Parameter()]$azurePasswordCred **#name (string)of the credentials**
)
$passwordCred = Get-AutomationPSCredential -Name $azurePasswordCred
Node "localhost"
{
User UserAdd
{
Ensure = "Present" # To ensure the user account does not exist, set Ensure to "Absent"
UserName = $username
FullName = "$username-fullname"
PasswordChangeRequired = $false
PasswordNeverExpires = $false
Password = $passwordCred # This needs to be a credential object
}
Group AddtoAdministrators
{
GroupName = "Administrators"
Ensure = "Present"
MembersToInclude = @($username)
}
}
} # end of Configuration
#
$cd = @{
AllNodes = @(
@{
NodeName = 'localhost'
PSDscAllowPlainTextPassword = $true
}
)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.