close

二、Samba 3.x 伺服器設定說明

設定Samba最基礎的項目就是指定工作群組名稱(workgroup)及網域名稱,編輯 Samba設定檔smb.conf,以下設定都在該檔案內[global]標籤下同一段落完成。
/etc/samba/smb.conf

workgroup = WEI
realm = WEI.COM

 

避免分享資源時出現亂碼,分別設定Windows、Linux的字集。

display charset = Big5
dos charset = CP950

 

使用AD網域認證必須修改Samba的安全層級,並指定認證主機及增加Windows網路相關設定。

security = ads
password server = ADSERVER.WEI.COM
wins server = ADSERVER.WEI.COM
encrypt passwords = yes

 

Linux預設的使用者家目錄為/home/使用者名稱,針對AD網域使用者 必須另行設定其家目錄位置,主要參數為:%D代表網域名稱、%U代表使用者名稱。以下設定目的為讓網域使用者的家目錄集中在/home/網域名稱/目錄下 並以使用者帳號命名,同時讓使用者帳號自動套用網域名稱及不允許使用者離線登入。

template homedir = /home/%D/%U
winbind use default domain = false
winbind offline logon = true

 

設定AD網域使用者帳號對應到Linux使用者帳號及群組的範圍。

idmap config * : range = 16777216-33554431

 

預設Winbind快取時間為300秒,使用指令# getent passwd或# getent group時,會將NT/AD網域的使用者與群組一併列出。當使用者、群組數量太多,Winbind會無法正常傳回資料,開啟此功能可以避免這個狀況。

winbind enum users = yes
winbind enum groups = yes
winbind cache time = 300

 

若允許AD網域使用者以終端機方式登入系統,可指定AD帳號的Shell。

template shell = /bin/bash

 

視需要開啟對NT ACLs(Access Control List) 的支援。

nt acl support = yes

 

三、整合Windows AD網域帳號資訊說明

當系統查詢使用者帳號與群組時,預設由檔案尋找(/etc/passwd、/etc/group),為了使其搜尋不到相關資訊時,轉而使用Winbind向AD網域查詢,必須設定認證來源和順序。
/etc/nsswitch.conf

passwd: files winbind
shadow: files winbind
group: files winbind

 

設定本機 UID 與 GID 發放範圍,避免 AD 帳號與 Linux 本機帳號衝突,限制本機分配給新使用者的uid、gid不要超過9999。
/etc/login.defs

UID_MIN 500
UID_MAX 9999
GID_MIN 500
GID_MAX 9999
CREATE_HOME yes

 

四、Linux Server加入AD網域

在將主機加入網域之前,需先確認AD主機及Linux主機時間不得相差超過5分鐘,建議設定同一網路校時服務(Network Time Protocol),並設定DNS或host使Linux主機得知AD網域伺服器的IP位址,任修改其中一種能查詢到網域即可。
/etc/resolv.conf

Nameserver 192.168.2.1

/etc/hosts

192.168.2.1        adserver.wei.com

 

由於Windows Server 2003的AD是採用Kerberos的認證機制,因此必須設定Kerberos相關設定檔以便和AD溝通。
/etc/krb5.conf

[logging]
 default = FILE:/var/log/krb5libs.log
 kdc = FILE:/var/log/krb5kdc.log
 admin_server = FILE:/var/log/kadmind.log

[libdefaults]
 default_realm = WEI.COM
 dns_lookup_realm = false
 dns_lookup_kdc = false
 ticket_lifetime = 24h
 renew_lifetime = 7d
 forwardable = true

 WEI.COM = {
  kdc = ADSERVER.WEI.COM
 }

/var/kerberos/krb5kdc/kdc.conf

[kdcdefaults]
 kdc_ports = 88
 kdc_tcp_ports = 88

[realms]
 WEI.COM = {
  master_key_type = aes256-cts
  acl_file = /var/kerberos/krb5kdc/kadm5.acl
  dict_file = /usr/share/dict/words
  admin_keytab = /var/kerberos/krb5kdc/kadm5.keytab
  supported_enctypes = aes256-cts:normal aes128-cts:normal des3-hmac-sha1:normal arcfour-hmac:normal des-hmac-sha1:normal des-cbc-md5:normal des-cbc-crc:normal
 }

 

完成以上設定後重新啟動Samba及Winbind並加入設開機啟動。

# service smb restart
# service winbind restart
# chkconfig smb on
# chkconfig winbind on

 

文字模式下指令加入wei.com 網域,aduser為AD網域之使用者,只需一般權限即可。

# net ads join -U aduser
aduser's password:

 

設定與AD伺服器溝通時的使用者(經測試是不需要作此動作的)。

# wbinfo --set-auth-user=aduser
Password:

 

一般Windows使用者在加入網域後存取不會有太大的問題,但Linux Clients使用者需要向Kerberos要求憑證(ticket)。可下指定測試取得Kerberos核發的憑證,取得後使用者不需要再輸入帳號密碼 存取資源,注意網域名稱要大寫,若密碼正確會跳回命令提示字元。

# kinit 網域帳號@WEI.COM

 

取得Kerberos核發的憑證後,可以看Kerberos核發的Kicket狀態。

# klist

 

測試讀取AD帳號資訊和取得系統帳號資訊。

# wbinfo -u | -g 取得網域帳號 | 群組
# getent passwd

 

參考文件:

http://michaeljoking.myip.org/modules/tad_book3/page.php?tbdsn=18

http://blog.yam.com/gavint/article/2590383

第2頁|全文共2頁
arrow
arrow
    文章標籤
    Linux samba winbind AD
    全站熱搜

    MIS 發表在 痞客邦 留言(0) 人氣()