운영체제/Linux

[Linux] SMB(SAMBA)를 이용한 AD Join ( AD LDAP)설정

louky 2020. 8. 4. 14:53
반응형

 

환경 

 - OS :  Centos 7.8

 - Kernel : 3.10.0-1127.13.1.el7.x86_64

 

sssd를 이용한  AD LDAP연동하는 바업도 있지만 SAMBA를 이용한 LDAP연동도 가능하다. 

 

 

 PKG설치 

[root@TEST ~]# yum install -y authconfig samba-winbind samba-client samba-winbind-clients

 

Join할 domain정보 resolv.conf에 추가 

[root@test ~]# echo "domain adserver.test.net" >> /etc/resolv.conf
[root@test ~]# vi /etc/nsswitch.conf
~(생략)
passwd:     files sss winbind
shadow:     files sss winbind
(저장)




[root@test ~]# vi /etc/krb5.conf
# Configuration snippets may be placed in this directory as well
includedir /etc/krb5.conf.d/

includedir /var/lib/sss/pubconf/krb5.include.d/
[logging]
 default = FILE:/var/log/krb5libs.log
 kdc = FILE:/var/log/krb5kdc.log
 admin_server = FILE:/var/log/kadmind.log

[libdefaults]
 dns_lookup_realm = true  #### false로 되어 있을 경우 true로 변경
 ticket_lifetime = 24h
 renew_lifetime = 7d
 forwardable = false    
 rdns = false
 pkinit_anchors = FILE:/etc/pki/tls/certs/ca-bundle.crt
# default_realm = EXAMPLE.COM
 default_ccache_name = KEYRING:persistent:%{uid}

 default_realm = TEST.NET
[realms]
# EXAMPLE.COM = {
#  kdc = kerberos.example.com
#  admin_server = kerberos.example.com
# }

 INFOBANK.NET = {
  kdc = adserver.test.net
 }

 INFOBANK.NET = {
  kdc = adserver.test.net
 }

[domain_realm]
# .example.com = EXAMPLE.COM
# example.com = EXAMPLE.COM

 

 

samba설정

[root@test ~]# vi  /etc/samba/smb.conf

# See smb.conf.example for a more detailed config file or
# read the smb.conf manpage.
# Run 'testparm' to verify the config is correct after
# you modified it.

[global]
#--authconfig--start-line--

# Generated by authconfig on 2020/08/04 14:32:59
# DO NOT EDIT THIS SECTION (delimited by --start-line--/--end-line--)
# Any modification may be deleted or altered by authconfig in future

   workgroup = test
   password server = adserver.test.net
   realm = TEST.NET
   security = ads
   idmap config * : range = 16777216-33554431
   template shell = /bin/bash
   template homedir = /home/test.net/%U       ## AD계정이 최조 로그인하면 생성되는 홈 디렉토리
   kerberos method = secrets only
   winbind use default domain = false
   winbind offline logon = false

#--authconfig--end-line--
;       workgroup = SAMBA
;       security = user

        passdb backend = tdbsam

        printing = cups
        printcap name = cups
        load printers = yes
        cups options = raw

[homes]
        comment = Home Directories
        valid users = %S, %D%w%S
        browseable = No
        read only = No
        inherit acls = Yes

[printers]
        comment = All Printers
        path = /var/tmp
        printable = Yes
        create mask = 0600
        browseable = No

[print$]
        comment = Printer Drivers
        path = /var/lib/samba/drivers
        write list = @printadmin root
        force group = @printadmin
        create mask = 0664
        directory mask = 0775

 

 

설정방법은 어렵지 않다. 

 

설정 1. authconfig-tui를 이용한 설정 

[root@TEST ~]# authconfig-tui

 authconfig-tui를 입력하면 구닥다리 같은 화면이 출력된다. 

 

A.설정 전 화면 

우측 "Winbind 인증 사용"에 체크를 한다.  방향키로 이동한다음에 스페이스 바를 누르면 선택이 된다. 

A,설정 후 화면

키보드의 탭키를 눌러 다음을 선택한다. 

 

LDAP  join할 AD서버 정보를 입력한다. 

 B. AD정보 설정 전

 

B. AD정보 설정 후 (예시)

보안모델 ads를 선택한다. 
도메인 도메인 정보를 입력한다. test.net이면 test만 입력한다. 
도메인제어기  시스템명 포함 도메인 주소를 입력한다.  adserver.test.net
ADS관리 영역 서브 도메인 정보를 제외한 도메인 정보를 입력한다. 
join된 계정이 사용할 shell를 선택한다.  해당 계정으로 로그인을 해야 함으로 /bin/bash를 선택

 

 

정상적으로Joindl 될 경우 

[/usr/bin/net join -w TEST -S adserver.test.net -U strator]
Enter strator's password:<...>

Using short domain name -- TEST
Joined 'test' to dns domain 'test.net'

 

 

<정상적으로 연동이  될 경우 >

[root@IB-DEVWINGO ~]#  authconfig-tui
You have new mail in /var/spool/mail/root

또는 

[root@IB-DEVWINGO ~]#  authconfig-tui
[/usr/bin/net join -w TEST -S adserver.test.net -U strator]
Enter strator's password:<...>

Using short domain name -- TEST
Joined 'test' to dns domain 'test.net'
No DNS domain configured for test. Unable to perform DNS Update.
DNS update failed: NT_STATUS_INVALID_PARAMETER
You have new mail in /var/spool/mail/root

 

<정상적으로 연동이 안 될 경우 >

[root@TEST ~]# authconfig-tui
Job for winbind.service failed because the control process exited with error code. See "systemctl status winbind.service" and "journalctl -xe" for details.
getsebool:  SELinux is disabled
getsebool:  SELinux is disabled
You have new mail in /var/spool/mail/root

 

 

# vi /etc/samba/smb.conf

~(생략)
   winbind use default domain = true      # false를 true로 변경한다. 
   winbind offline logon = true              # false를 true로 변경한다.

 

AD계정으로  처음 로그온 할 때 로컬 홈을 만들려면 아래 명령을 실행한다.

[root@test ~]# authconfig --enablemkhomedir --update

서비스 daemon 재시작

여기서는 winbind  daemon만 재시작하면 된다. 

 

[root@test ~]# systemctl restart winbind
You have new mail in /var/spool/mail/root

 

 

정상적으로 AD와  join이 되었다면 아래 명령어를 통해 AD 내 group정보 및 사용자 정보를 출력할 수 있다. 

 

 

반응형