介紹
適用於:Linux 上的 SQL Server
adutil 工具是一款命令列介面(CLI)工具,用於配置和管理Linux 上的 SQL Server與容器的Windows Active Directory域。 它消除了在 Windows 與 Linux 機器間切換來管理 Active Directory 的需求。
Note
adutil 的支援僅限於SQL Server使用情境。 你也可以使用其他工具,如 ktpass來啟用Active Directory認證,詳見 教學:使用 Linux 上的 SQL Server 使用Active Directory認證。
在開始之前,務必先下載 adutil 到已經加入Active Directory網域的主機上。
這個 adutil 工具設計成一系列指令和子指令,並有額外的標記,你可以指定作為進一步輸入。 每個頂層指令代表一類行政功能。 在該類別中,每個子命令都是一項作業。 本文將教你如何下載並開始使用 adutil。
設定 adutil 為透過安全套接層(SSL)的 LDAP
您應該使用透過 SSL 的輕量型目錄存取通訊協定 (LDAPS) 來取代輕量型目錄存取通訊協定 (LDAP)。 欲了解更多關於 LDAP 的資訊,請參閱輕量目錄存取協定(LDAP)。
你可以在useLdaps設定檔裡,將true選項設定為adutil.json。 以adutil使用者身份運行mssql時,設定檔位於/var/opt/mssql/.adutil/adutil.json。 此 JSON 程式碼範例示範如何進行設定:
{
"useLdaps": "true"
}
根據預設,useLdaps 是 false。 當你設定這個設定並使用mssql-conf來建立 keytab(鍵表)時,務必以使用者身份執行mssql-confmssql。 執行以下指令切換至使用者:mssql
sudo su mssql
要使用 mssql-conf 設定鍵頁,請參見 使用 mssql-conf 建立 SQL Server 服務鍵鍵頁檔案。
安裝 adutil
如果你在安裝時不接受最終使用者授權協議(EULA),第一次執行指令 adutil 時,必須使用 --accept-eula 該標誌執行(適用於所有發行版)。
下載 Microsoft Red Hat 儲存庫設定檔。
雷爾 10
sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/10/prod.repo雷爾 9
sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/9/prod.repoRHEL 8
sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/8/prod.repo如果你安裝的是先前的預覽版
adutil,請使用以下指令移除所有舊adutil的套件。sudo yum remove adutil-preview要安裝
adutil,請執行以下指令。ACCEPT_EULA=Y接受adutil的 EULA。 EULA 位於/usr/share/adutil/。sudo ACCEPT_EULA=Y yum install -y adutil
使用 adutil 來管理Windows Active Directory
請確定您將 adutil 下載至已加入 Active Directory 網域的主機。 您也需要使用 kinit 命令和特殊權限網域帳戶,取得或更新 Kerberos TGT (票證授權票證)。 您使用的帳戶必須具有在網域上建立帳戶和服務主體名稱 (SPN) 的權限。
以下是您可以使用 adutil 執行的一些動作範例。 若要查看最上層命令清單,請鍵入 adutil --help。 此命令會顯示可用來管理 Active Directory 並與其互動的最上層命令。
adutil --help
您會看到下列輸出:
adutil - A general AD utility
Usage:
adutil [account|delegation|group|keytab|machine|ou|spn|user|config]
Subcommands:
account Functions for generic account operations
delegation Functions for configuring delegation permissions
group Functions for group management
keytab Functions for keytab management
machine Functions for managing machine accounts
ou Functions for managing organizational units
spn Functions for service principal name (SPN) management
user Functions for user account management
config Functions for modifying adutil configuration
Flags:
--version Displays the program version string.
-h --help Displays help with available flag, subcommand, and positional value parameters.
-d --debug Display additional debugging information when making LDAP/Kerberos calls.
--accept-eula Accepts the current EULA for adutil. This has no effect if the EULA has already been accepted.
要獲得較低階指令的幫助,請使用以下範例:
spn命令:adutil spn --helpspn search命令:adutil spn search --help
範例
每個命令都有說明,因此您可以立即開始使用。 以下是adutil在配置或執行Linux 上的 SQL Server與容器Active Directory認證時常用的一些典型活動:
在 Active Directory 建立帳號:
adutil user create --name sqluser --distname CN=sqluser,CN=Users,DC=CONTOSO,DC=COM建立與帳戶或服務相關聯的 SPN:
adutil spn addauto -n sqluser -s MSSQLSvc -H mymachine.contoso.com -p 1433使用以下方式
adutil製作密鑰表:adutil keytab createauto -k /var/opt/mssql/secrets/mssql.keytab -p 1433 -H mymachine.contoso.com --password '<password>' -s MSSQLSvc注意事項
您的密碼應遵循 SQL Server 預設 密碼原則。 根據預設,密碼長度必須至少為8個字元,且包含下列四個集合中的三個字元:大寫字母、小寫字母、基底10位數和符號。 密碼長度最多可達 128 個字元。 盡可能使用長且複雜的密碼。
欲了解更多資訊,請參閱adutil參考手冊頁,並使用man adutil查看。