웹사이트 검색

CentOS 7에 Samba 4 도메인 컨트롤러 설치


이 페이지에서

  1. Samba 4 설치
  2. 도메인에 Windows 호스트 추가\n
  3. Windows 10에 RSAT 도구 설치
  4. CentOS 7에서 Samba 4로 클라이언트 인증
  5. CentOS 6에서 Samba 4로 클라이언트 인증

버전 4.0부터 Samba는 AD(Active Directory) 도메인 컨트롤러(DC)로 실행할 수 있습니다. 이 자습서에서는 Windows 10, CentOS 7 및 CentOS 6 클라이언트를 사용하여 Samba 4를 도메인 컨트롤러로 구성하는 방법을 보여줍니다.

이 튜토리얼에서는 소스에서 Samba 4를 컴파일합니다. Samba 4 RPM 기반 설치 및 Samba 4용 SELinux 구성을 찾고 있다면 여기에서 저의 새로운 Samba 4 튜토리얼을 참조하십시오.

저는 3개의 시스템, CentOS 7 서버 1개, 원격 관리용 Windows 10 클라이언트, CentOS 7 및 CentOS 6 클라이언트를 사용할 것입니다.

  • 192.168.1.190 Samba4 AD centos7
  • 192.168.1.191 원격 관리 승리 10
  • 192.168.1.22 - 클라이언트 인증 - centos 7
  • 192.168.1.192 - 클라이언트 인증 - centos 6

삼바 4 설치

192.168.1.190 Samba4 AD centos 7

Basis는 최소 설치 및 SELinux가 비활성화된 CentOS 7입니다.

      
[ ~]# sestatus
SELinux status: disabled
[ ~]#
      

/etc/hosts 파일에 항목을 만듭니다.

[ ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.190   samba4.sunil.cc samba4
[ ~]#
      

epel 저장소를 설치합니다.

[ ~]# yum install epel-release -y

samba4를 컴파일하는 데 필요한 모든 패키지를 설치합니다.

[ ~]# yum install perl gcc libacl-devel libblkid-devel gnutls-devel readline-devel python-devel gdb pkgconfig krb5-workstation zlib-devel setroubleshoot-server libaio-devel setroubleshoot-plugins\
policycoreutils-python libsemanage-python setools-libs-python setools-libs popt-devel libpcap-devel sqlite-devel libidn-devel libxml2-devel libacl-devel libsepol-devel libattr-devel keyutils-libs-devel\
cyrus-sasl-devel cups-devel bind-utils libxslt docbook-style-xsl openldap-devel pam-devel bzip2 vim wget -y

이제 samba4 패키지를 다운로드하십시오. 이 설정 중에 최신인 samba-4.6.0을 사용합니다.

[ ~]#  wget https://download.samba.org/pub/samba/stable/samba-4.6.0.tar.gz

이제 samba4를 설치합시다.

  [ ~]# tar -zxvf samba-4.6.0.tar.gz
  [ ~]# cd samba-4.6.0
  [ samba-4.6.0]# ./configure --enable-debug --enable-selftest --with-ads --with-systemd --with-winbind
  [ samba-4.6.0]# make && make install
  

설치는 시스템 속도에 따라 약 10분 정도 소요됩니다.

이제 도메인 프로비저닝을 수행합니다.

[ samba]# samba-tool domain provision --use-rfc2307 --interactive
Realm [SUNIL.CC]:
 Domain [SUNIL]:
 Server Role (dc, member, standalone) [dc]: dc
 DNS backend (SAMBA_INTERNAL, BIND9_FLATFILE, BIND9_DLZ, NONE) [SAMBA_INTERNAL]:
 DNS forwarder IP address (write 'none' to disable forwarding) [4.2.2.1]:
Administrator password:
Retype password:
Looking up IPv4 addresses
Looking up IPv6 addresses
No IPv6 address will be assigned
Setting up share.ldb
Setting up secrets.ldb
Setting up the registry
Setting up the privileges database
Setting up idmap db
Setting up SAM db
Setting up sam.ldb partitions and settings
Setting up sam.ldb rootDSE
Pre-loading the Samba 4 and AD schema
Adding DomainDN: DC=sunil,DC=cc
Adding configuration container
Setting up sam.ldb schema
Setting up sam.ldb configuration data
Setting up display specifiers
Modifying display specifiers
Adding users container
Modifying users container
Adding computers container
Modifying computers container
Setting up sam.ldb data
Setting up well known security principals
Setting up sam.ldb users and groups
ERROR(ldb): uncaught exception - operations error at ../source4/dsdb/samdb/ldb_modules/password_hash.c:2820
  File "/usr/local/samba/lib64/python2.7/site-packages/samba/netcmd/__init__.py", line 176, in _run
    return self.run(*args, **kwargs)
  File "/usr/local/samba/lib64/python2.7/site-packages/samba/netcmd/domain.py", line 471, in run
    nosync=ldap_backend_nosync, ldap_dryrun_mode=ldap_dryrun_mode)
  File "/usr/local/samba/lib64/python2.7/site-packages/samba/provision/__init__.py", line 2175, in provision
    skip_sysvolacl=skip_sysvolacl)
  File "/usr/local/samba/lib64/python2.7/site-packages/samba/provision/__init__.py", line 1787, in provision_fill
    next_rid=next_rid, dc_rid=dc_rid)
  File "/usr/local/samba/lib64/python2.7/site-packages/samba/provision/__init__.py", line 1447, in fill_samdb
    "KRBTGTPASS_B64": b64encode(krbtgtpass.encode('utf-16-le'))
  File "/usr/local/samba/lib64/python2.7/site-packages/samba/provision/common.py", line 55, in setup_add_ldif
    ldb.add_ldif(data, controls)
  File "/usr/local/samba/lib64/python2.7/site-packages/samba/__init__.py", line 225, in add_ldif
    self.add(msg, controls)

[ samba]#

도메인 프로비저닝을 할 때 약간의 오류가 있습니다.

문제를 해결하려면 /etc/krb5.conf에서 아래 행을 주석 처리하십시오.

  --------
  #includedir /etc/krb5.conf.d/
  --------

도메인 프로비저닝을 다시 실행하면 이제 도메인이 오류 없이 생성됩니다.

  [ etc]# samba-tool domain provision --use-rfc2307 --interactive
Realm [SUNIL.CC]:
 Domain [SUNIL]:
 Server Role (dc, member, standalone) [dc]:
 DNS backend (SAMBA_INTERNAL, BIND9_FLATFILE, BIND9_DLZ, NONE) [SAMBA_INTERNAL]:
 DNS forwarder IP address (write 'none' to disable forwarding) [4.2.2.1]:
Administrator password:
Retype password:
Looking up IPv4 addresses
Looking up IPv6 addresses
No IPv6 address will be assigned
Setting up secrets.ldb
Setting up the registry
Setting up the privileges database
Setting up idmap db
Setting up SAM db
Setting up sam.ldb partitions and settings
Setting up sam.ldb rootDSE
Pre-loading the Samba 4 and AD schema
Adding DomainDN: DC=sunil,DC=cc
Adding configuration container
Setting up sam.ldb schema
Setting up sam.ldb configuration data
Setting up display specifiers
Modifying display specifiers
Adding users container
Modifying users container
Adding computers container
Modifying computers container
Setting up sam.ldb data
Setting up well known security principals
Setting up sam.ldb users and groups
Setting up self join
Adding DNS accounts
Creating CN=MicrosoftDNS,CN=System,DC=sunil,DC=cc
Creating DomainDnsZones and ForestDnsZones partitions
Populating DomainDnsZones and ForestDnsZones partitions
Setting up sam.ldb rootDSE marking as synchronized
Fixing provision GUIDs
A Kerberos configuration suitable for Samba AD has been generated at /usr/local/samba/private/krb5.conf
Setting up fake yp server settings
Once the above files are installed, your Samba4 server will be ready to use
Server Role:           active directory domain controller
Hostname:              samba4
NetBIOS Domain:        SUNIL
DNS Domain:            sunil.cc
DOMAIN SID:            S-1-5-21-2936486394-2075362935-551615353

[ etc]#
  

방화벽에서 포트가 열려 있는지 확인하십시오.

[ etc]#firewall-cmd --add-port=53/tcp --permanent;firewall-cmd --add-port=53/udp --permanent;firewall-cmd --add-port=88/tcp --permanent;firewall-cmd --add-port=88/udp --permanent; \
firewall-cmd --add-port=135/tcp --permanent;firewall-cmd --add-port=137-138/udp --permanent;firewall-cmd --add-port=139/tcp --permanent; \
firewall-cmd --add-port=389/tcp --permanent;firewall-cmd --add-port=389/udp --permanent;firewall-cmd --add-port=445/tcp --permanent; \
firewall-cmd --add-port=464/tcp --permanent;firewall-cmd --add-port=464/udp --permanent;firewall-cmd --add-port=636/tcp --permanent; \
firewall-cmd --add-port=1024-5000/tcp --permanent;firewall-cmd --add-port=3268-3269/tcp --permanent
[ ~]# firewall-cmd --reload
  

재부팅하는 동안 서비스를 자동 시작하는 시작 스크립트를 만듭니다.

[ ~]# cat /etc/systemd/system/samba.service
[Unit]
Description= Samba 4 Active Directory
After=syslog.target
After=network.target

[Service]
Type=forking
PIDFile=/usr/local/samba/var/run/samba.pid
ExecStart=/usr/local/samba/sbin/samba

[Install]
WantedBy=multi-user.target
[ ~]#

[ ~]# systemctl enable samba
Created symlink from /etc/systemd/system/multi-user.target.wants/samba.service to /etc/systemd/system/samba.service.
[ ~]# systemctl start samba
  

도메인에 Windows 호스트 추가

192.168.1.191 원격 관리 승리 10

호스트가 정적 ipaddress로 추가되었는지 확인하십시오.

호스트를 도메인에 추가합니다.

Windows에서 Samba4를 관리하려면 Microsoft RSAT(원격 서버 도구)를 설치해야 합니다.

위키 페이지에는 https://wiki.samba.org/index.php/Installing_RSAT 링크가 있습니다.

Windows 10에 RSAT 도구 설치

설치 프로그램을 실행합니다.

재부팅 후 실행으로 이동하여 dsa.msc를 입력합니다.

sunil.cc 도메인을 클릭하고 새로 만들기 -> 사용자를 마우스 오른쪽 버튼으로 클릭합니다.

테스트 사용자 생성.

CentOS 7에서 Samba 4로 클라이언트 인증

192.168.1.22 - CentOS 7의 클라이언트 인증

패키지 설치:

[ ~]# yum -y install realmd sssd oddjob oddjob-mkhomedir adcli samba-common

samba4와의 연결 확인:

   [ ~]# realm discover SUNIL.CC
sunil.cc
  type: kerberos
  realm-name: SUNIL.CC
  domain-name: sunil.cc
  configured: kerberos-member
  server-software: active-directory
  client-software: sssd
  required-package: oddjob
  required-package: oddjob-mkhomedir
  required-package: sssd
  required-package: adcli
  required-package: samba-common-tools
  login-formats: %U
  login-policy: allow-realm-logins
[ ~]#
   

도메인에 가입합니다.

[ ~]#  realm join SUNIL.CC
Password for Administrator:
[ ~]#

samba4에서 사용자를 가져올 수 있는지 확인하십시오.

[ ~]# id SUNIL\\testuser
uid=1570001104()
[ ~]#

SSD를 구성합니다.

[ ~]# cat /etc/sssd/sssd.conf

[sssd]
domains = sunil.cc
config_file_version = 2
services = nss, pam

[domain/sunil.cc]
ad_domain = sunil.cc
krb5_realm = SUNIL.CC
realmd_tags = manages-system joined-with-samba
cache_credentials = True
id_provider = ad
krb5_store_password_if_offline = True
default_shell = /bin/bash
ldap_id_mapping = True
use_fully_qualified_names = True
fallback_homedir = /home/%%d
access_provider = ad
[ ~]#

SSD를 다시 시작하십시오.

[ ~]# systemctl restart sssd
[ ~]# systemctl enable sssd

사용자를 확인하십시오.

[
uid=1570001105()
[ ~]#

도메인 이름 없이 사용자를 얻으려면.

[ ~]# vim /etc/sssd/sssd.conf
-----------
------------
use_fully_qualified_names = False
-----------
-----------

sssd를 다시 시작하고 id 명령을 확인하십시오.

[ ~]# systemctl restart sssd
[ ~]# id sambauser
uid=1570001105(sambauser) gid=1570000513(domain users) groups=1570000513(domain users),1570000512(domain admins),1570000572(denied rodc password replication group)
[ ~]#

CentOS 6에서 Samba 4로 클라이언트 인증

192.168.1.192 - CentOS 6의 클라이언트 인증.

패키지 설치.

   [ db]#  yum install pam pam_ldap pam_krb5 sssd sssd-ldap sssd-common authconfig oddjob oddjob-mkhomedir openldap openldap-clients krb5-workstation adcli -y
   

Kerberos 구성 파일을 변경합니다.

   [ db]# cat /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 = SUNIL.CC
 dns_lookup_realm = false
 dns_lookup_kdc = false
 ticket_lifetime = 24h
 renew_lifetime = 7d
 forwardable = true

[realms]
 SUNIL.CC = {
  kdc = samba4.sunil.cc
  admin_server = samba4.sunil.cc
 }

[domain_realm]
 .sunil.cc = SUNIL.CC
 sunil.cc = SUNIL.CC
[ db]#

   

adcli 명령을 사용하여 도메인에 가입합니다.

   [ db]# adcli info sunil.cc
[domain]
domain-name = sunil.cc
domain-short = SUNIL
domain-forest = sunil.cc
domain-controller = samba4.sunil.cc
domain-controller-site = Default-First-Site-Name
domain-controller-flags = pdc gc ldap ds kdc timeserv closest writable good-timeserv full-secret
domain-controller-usable = yes
domain-controllers = samba4.sunil.cc
[computer]
computer-site = Default-First-Site-Name
[ db]#
[ db]# adcli join sunil.cc
Password for :
[ db]#
   

Kerberos 티켓이 생성되었는지 확인하십시오.

   [ db]# klist -ke
   

인증을 구성합니다.

   [ db]# authconfig --enablesssd --enablesssdauth --enablemkhomedir --update
   

지금 sssd 구성을 수정하여 인증을 수행하십시오.

   [ db]# cat /etc/sssd/sssd.conf
[sssd]
services = nss, pam, ssh, autofs
config_file_version = 2
domains = sunil.cc

[domain/sunil.cc]
id_provider = ad
# Uncomment if service discovery is not working
# ad_server = server.win.example.com
default_shell = /bin/bash
fallback_homedir = /home/%u
[ db]#
   

sssd 서비스를 다시 시작하십시오.

   [ db]# chkconfig sssd on
[ db]# service sssd restart
Stopping sssd:                                             [  OK  ]
Starting sssd:                                             [  OK  ]
[ db]#
   

사용자를 확인하는 중입니다.

   [ db]# id sambauser
uid=1570001105(sambauser) gid=1570000513(domain users) groups=1570000513(domain users),1570000512(domain admins),1570000572(denied rodc password replication group)
[ db]#