[英]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.