1. 程式人生 > >Ubuntu通過samba winbind集成AD賬號

Ubuntu通過samba winbind集成AD賬號

用戶名 ken inb 開始 rep workgroup amba word 圖形化

Ubuntu通過samba winbind集成AD賬號:

安裝軟件:

apt-get install samba krb5-config krb5-user winbind libpam-winbind libnss-winbind

輸入ming.com

vi /etc/nsswitch.conf

passwd: compat winbind
group: compat winbind
shadow: compat winbind

:wq

vi /etc/krb5.conf ([realms]下面其它的都可刪掉)

[libdefaults]
default_realm = MING.COM (此處必須為大寫)

[realms]
spreadtrum.com = {
kdc = 10.0.0.2:88
kdc = 10.0.0.3:88
default_domain = ming.com
}

:wq

kinit zhi.ming (能加域的普通AD賬號即可)

輸入賬號密碼

klist

vi /etc/samba/smb.conf

[global]

  workgroup = ming
  realm = ming.com
  netbios name = aa
  security = ADS
  dns forwarder = 10.0.0.1
  idmap config *:backend = tdb
  idmap config *:range = 50000-1000000

  template homedir = /home/%D/%U
  template shell = /bin/bash
  winbind use default domain = true
  winbind offline  logon = true
  winbind nss info  = rfc2307
  winbind enum users = yes
  winbind enum groups = yes
  vfs objects = acl_xattr
  map acl inherit = Yes
  store dos attributes = Yes

:wq

vi /etc/pam.d/common-account (自動創建家目錄)

session required pam_mkhomedir.so skel=/etc/skel/ umask=0022
:wq

vi /etc/pam.d/common-password

password [success=1 default=ignore] pam_winbind.so try_first_pass (將默認的use_authtok去掉)

:wq

service smbd restart

service nmbd restart

net ads join -U zhi.ming (能加域的普通AD賬號即可)

輸入AD賬號密碼

註:
/etc/hosts裏的主機名及域名要和加的AD域一致(不一致會加不進去)

service winbind restart

wbinfo -u (查看AD裏的賬號信息)

wbinfo -g (查看AD裏的group信息)

getent passwd | grep zhi.ming

id zhi.ming

su - zhi.ming

遠程ssh:

ssh [email protected]

給sudo權限:

給個人:

vi /etc/sudoers

zhi.ming ALL=(ALL:ALL) NOPASSWD:ALL

:wq

給group(未成):

%MING\domain\ users ALL=(ALL:ALL) NOPASSWD:ALL

支持圖形化登陸:

vi /usr/share/lightdm/lightdm.conf/50-ubuntu.conf

greeter-show-manual-login=true
greeter-hide-users=true

:wq

登陸時為ming\zhi.ming (即前要加域名)

註:

1、賬號的uid和gid根據訪問的先後順利從50000開始排序(/etc/samba/smb.conf定義的),無法在AD裏自定義
2、所有賬號均可登錄,無法通過/etc/passwd進行限制

通過AD域賬號訪問samba共享:

共享homes:

vi /etc/samba/smb.conf

[homes]
comment = Home Directories
browseable = no
writable = yes
valid users = %S

 :wq

 # service smbd restart

 訪問:\\ip\zhi.ming    (此時不需要輸用戶名密碼直接就可以訪問自己家目錄,訪問不了別人的)

 共享特定目錄:

 # vi /etc/samba/smb.conf

 [share]
comment = share
path = /space/share
browseable = yes
writable = yes
valid users = MING\zhi.ming
    :wq

    訪問:\\ip\share     (此時不需要輸用戶名密碼直接就可以訪問)

Ubuntu通過samba winbind集成AD賬號