Windows AD 與 Certificate Service 安裝筆記
source link: https://blog.darkthread.net/blog/setup-ad-n-ca/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
遇到一堆跟憑證有關的 Windows 服務問題,想自己架個 Windows CA 做研究,開了 VM,練習用 PowerShell 安裝 AD 及 CA 伺服器。
安裝 AD Domain Controller (AD DS)
- 若 Win Server 原本用 DHCP,要先改為靜態固定 IP,設定 DNS 伺服器
Get-NetIPAddress | Select InterfaceIndex, IPAddress # 主要是看網路介面代號 InterfaceIndex,等下當成參數 Get-NetIPConfiguration # 可查 IP、Gateway、DNS New-NetIPAddress -InterfaceIndex 4 -IPAddress 192.168.50.228 -PrefixLength 24 DefaultGateway 192.168.50.1 # 將自己的 IP 設成第一 DNS 主機,後接一般 DNS Set-DnsClientServerAddress -InterfaceIndex 4 -ServerAddresses ("192.168.50.228","8.8.8.8")
- 主機改名
如果當初安裝時沒指定,主機名稱會是 WIN-K6RT2R4NDIM 這種隨機名稱,由於未來常要輸入 DC 主機名稱,建議取個 dc 之類的簡短名稱比較省事。$env:COMPUTERNAME # 查現有主機名稱 Rename-ComputerName DC # 改完要重開機 Restart-Computer # 重開機
- 安裝 AD-DS 角色
Install-WindowsFeature –Name AD-Domain-Services –IncludeManagementTools
- 建立 AD Forest 註1:DomainMode,Win 2016+ 設 7 (WinThreshold)、ForestMode 7 = Windows2016Forest
Install-ADDSForest ` -DomainName "utopia.net" ` -CreateDnsDelegation:$false ` -DatabasePath "C:\Windows\NTDS" ` -DomainMode "7" ` -DomainNetbiosName "utopia" ` -ForestMode "7" ` -InstallDns:$true ` -LogPath "C:\Windows\NTDS" ` -NoRebootOnCompletion:$true ` -SysvolPath "C:\Windows\SYSVOL" ` -Force:$true
註2:建立時要輸入 Safe Mode Administrator Password,執行 AD 修復還原時使用 - 重開重新登入後,用以下指令檢查 AD 相關服務是否就緒 若四個服務都在 Running,代表 AD 安裝成功。
Get-Service adws,kdc,netlogon,dns
參考文件:Windows server 2019 Step-By-Step: Setup Active Directory environment using PowerShell
安裝 Certification Authority (AD CS)
- 安裝相關程式
Add-WindowsFeature Adcs-Cert-Authority -IncludeManagementTools
- 建立 Enterprise CA 註:CAType 分為 EnterpriseRootCa 與 StandaloneRootCa,EnterpriseRootCa 與 AD 緊密整合,可設定憑證範本讓 Windows 主機、服務自動取得及更新憑證,同時可備份使用者加密憑證,萬一遺失時還能救回來。StandaloneRootCa 則可當成單純 CA 使用,簽發憑證全手動,且需自行備妥複雜的憑證資訊確保有效性,但優點時可平日停機,需要才啟動,降低曝露風險。參考
Install-AdcsCertificationAuthority -CAType EnterpriseRootCA
- 如果想像坊間教學在 IIS 建立憑證 Request 檔,上傳到 CA 網站產生 TLS 憑證,還需要安裝 Certification Authority Web Enrollment
Add-WindowsFeature Adcs-Web-Enrollment
Install-AdcsWebEnrollment
安裝完成,輸入 ℎttp://dc.utpia.net/certsvr,看到以下畫面就成功了。
參考文件:Install the Certification Authority
CA 裝好,馬上發一張 4096 bit 的 IIS 憑證給自己開心一下,哈!
- Posted in
- IIS
Comments
Be the first to post a comment
Post a comment
CommentRecommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK