공유를 지원하는 CentOS 7 rpm 기반 설치에서 Active Directory가 포함된 Samba 4
이 페이지에서
- CentOS 7 서버 준비
- CentOS 7에 Samba 4 설치
- Samba 4 구성
- Windows ACL 지원으로 Samba 공유 만들기
- Samba 공유 만들기
지난 튜토리얼에서는 RedHat에서 제공하는 패키지가 Active Directory를 지원하지 않기 때문에 소스에서 Samba를 컴파일하여 Centos 7에서 Samba를 구성하는 방법을 보여주었습니다. samba4 rpm에 AD 지원을 제공하는 Wing이라는 저장소가 있다는 것을 알게 되었습니다. 이 튜토리얼에서는 Samba 설치를 위해 이 리포지토리를 사용합니다. 또한 삼바 공유를 만드는 방법도 보여 드리겠습니다.
이 튜토리얼에서는 SELinux가 활성화된 기반으로 최소 설치의 CentOS 7 서버를 사용합니다.
CentOS 7 서버 준비
SELinux 상태를 확인하십시오.
[ ~]# sestatus SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: targeted Current mode: enforcing Mode from config file: enforcing Policy MLS status: enabled Policy deny_unknown status: allowed Max kernel policy version: 28 [ ~]#
서버 IP 주소, 전체(fqdn) 호스트 이름, 호스트 이름의 로컬 부분 순으로 호스트 파일에 항목을 만듭니다.
[ ~]# 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 CentOS 저장소를 설치합니다.
[ ~]# yum install epel-release -y
기본 패키지를 설치합니다.
[ ~]# yum install vim wget authconfig krb5-workstation -y
이제 윙 레포를 설치합니다.
[ ~]# cd /etc/yum.repos.d/ [ yum.repos.d]# wget http://wing-net.ddo.jp/wing/7/EL7.wing.repo [' /etc/yum.repos.d/EL7.wing.repo [ yum.repos.d]# yum clean all Loaded plugins: fastestmirror Cleaning repos: base extras updates wing wing-source Cleaning up everything Cleaning up list of fastest mirrors [ yum.repos.d]#
CentOS 7에 Samba 4 설치
yum을 사용하여 wing 저장소에서 Samba4 패키지를 설치합니다.
[ yum.repos.d]# yum install -y samba45 samba45-winbind-clients samba45-winbind samba45-client\ samba45-dc samba45-pidl samba45-python samba45-winbind-krb5-locator perl-Parse-Yapp\ perl-Test-Base python2-crypto samba45-common-tools
이 파일을 제거하십시오.
[ ~]# rm -rf /etc/krb5.conf [ ~]# rm -rf /etc/samba/smb.conf
삼바 4 구성
이제 도메인 프로비저닝을 수행합니다.
[ ~]# 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 4 has been generated at /var/lib/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-1578983437-3114190590-2362936743 [ 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-3500/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=/var/run/samba.pid ExecStart=/usr/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 restart samba
다른 모든 단계는 이전 기사와 유사합니다.
Windows 및 Linux 호스트를 구성하려면 참조하십시오.
소스에서 Samba4 도메인 컨트롤러 설치
Windows ACL 지원으로 Samba 공유 만들기
samba4용 확장 ACL을 구성해야 합니다. global 아래의 smb.conf 파일에 다음을 추가합니다.
[ ~]# cat /etc/samba/smb.conf # Global parameters [global] ------------ ------------- vfs objects = acl_xattr map acl inherit = yes store dos attributes = yes ------------ ------------- [ ~]#
이제 Samba 서비스를 다시 시작하십시오.
[ ~]# systemctl restart samba
SeDiskOperatorPrivilege 권한이 부여된 사용자 및 그룹만 공유 권한을 구성할 수 있습니다.
[ ~]# net rpc rights grant "SUNIL\Domain Admins" SeDiskOperatorPrivilege -U "USER\administrator" Enter USER\administrator's password: Successfully granted rights. [ ~]#
공유를 생성하기 전에 samba4 서버가 자체적으로 인증되는지 확인해야 합니다.
wing의 기존 패키지가 RedHat에서 제공하는 패키지와 충돌하므로 작동하지 않기 때문에 일반적인 방법을 사용할 수 없습니다. 여기서는 sssd를 사용할 수 없습니다. 이 작업을 수행하기 위해 winbind를 사용할 것입니다.
아래의 방법을 이용해주세요. 이것은 특정 권한으로 samba 공유를 생성하는 데 필요합니다.
아래 패키지를 설치합니다.
[ ~]#yum -y install authconfig-gtk*
명령을 실행합니다.
[ yum.repos.d]# authconfig-tui
winbind를 선택하고 다음 단계를 따르십시오.




암호를 입력할 수 없으므로 확인을 누르십시오.
그런 다음 /etc/samba/smb.conf에서 줄을 주석 처리하고 samba 서비스를 다시 시작합니다.
구성은 다음과 같아야 합니다.
[ ~]# cat /etc/samba/smb.conf # Global parameters [global] #--authconfig--start-line-- # Generated by authconfig on 2017/05/26 17:23:04 # DO NOT EDIT THIS SECTION (delimited by --start-line--/--end-line--) # Any modification may be deleted or altered by authconfig in future # workgroup = SUNIL # password server = samba4.sunil.cc # realm = SUNIL.CC # security = ads # idmap config * : range = 16777216-33554431 # template shell = /sbin/nologin # kerberos method = secrets only # winbind use default domain = false # winbind offline logon = false #--authconfig--end-line-- netbios name = SAMBA4 realm = SUNIL.CC workgroup = SUNIL dns forwarder = 4.2.2.1 server role = active directory domain controller idmap_ldb:use rfc2307 = yes vfs objects = acl_xattr map acl inherit = yes store dos attributes = yes [netlogon] path = /var/lib/samba/sysvol/sunil.cc/scripts read only = No [sysvol] path = /var/lib/samba/sysvol read only = No [ ~]# [ ~]# systemctl restart samba
사용자 및 그룹을 채울 수 있는지 확인하십시오.
[ ~]# wbinfo -u SUNIL\administrator SUNIL\sambauser SUNIL\testuser SUNIL\krbtgt SUNIL\guest [ ~]# wbinfo -g SUNIL\cert publishers SUNIL\ras and ias servers SUNIL\allowed rodc password replication group SUNIL\denied rodc password replication group SUNIL\dnsadmins SUNIL\enterprise read-only domain controllers SUNIL\domain admins SUNIL\domain users SUNIL\domain guests SUNIL\domain computers SUNIL\domain controllers SUNIL\schema admins SUNIL\enterprise admins SUNIL\group policy creator owners SUNIL\read-only domain controllers SUNIL\dnsupdateproxy [ ~]#
nsswitch.conf에서 행을 수정합니다.
[ ~]# cat /etc/nsswitch.conf ---------- --------- passwd: files winbind shadow: files winbind group: files winbind hosts: files dns wins services: files winbind netgroup: files winbind --------- ----------
이제 id 명령을 사용하여 사용자 이름을 얻을 수 있는지 확인합니다.
[ ~]# id testuser uid=3000019(SUNIL\testuser) gid=100(users) groups=100(users),3000019(SUNIL\testuser),3000009(BUILTIN\users) [ ~]#
Samba 공유 생성
하나는 테스트 사용자만 액세스할 수 있고 다른 하나는 도메인 사용자 그룹의 모든 사용자가 액세스할 수 있는 두 개의 공유를 만들 것입니다.
testuser가 액세스할 수 있는 공유는 testshare라고 합니다.
모든 사용자가 액세스할 수 있는 공유를 commonshare라고 합니다.
[ ~]# mkdir /testshare [ ~]# mkdir /commonshare [ ~]# chmod 770 /testshare [ ~]# chmod 770 /commonshare [ ~]# chown -R root:testuser /testshare [ ~]# chown -R root:"Domain Users" /commonshare
이제 smb.conf에 항목을 추가하십시오.
[ ~]# cat /etc/samba/smb.conf # Global parameters [global] netbios name = SAMBA4 realm = SUNIL.CC workgroup = SUNIL dns forwarder = 4.2.2.1 server role = active directory domain controller idmap_ldb:use rfc2307 = yes vfs objects = acl_xattr map acl inherit = yes store dos attributes = yes [netlogon] path = /var/lib/samba/sysvol/sunil.cc/scripts read only = No [sysvol] path = /var/lib/samba/sysvol read only = No [TestShare] comment = Test share accessible by testuser path = /testshare valid users = SUNIL\testuser writable = yes read only = no force create mode = 0660 create mask = 0770 directory mask = 0770 force directory mode = 0770 access based share enum = yes hide unreadable = yes [CommonShare] comment = Accessible by all the users path = /commonshare valid users = "@SUNIL\Domain Users" writable = yes read only = no force create mode = 0660 create mask = 0777 directory mask = 0777 force directory mode = 0770 access based share enum = yes hide unreadable = yes [ ~]#
삼바 서비스를 다시 시작하십시오.
[ ~]# systemctl restart samba
테스트 사용자로 samba 공유에 액세스합니다.

여기에서 testshare와 commonshare가 모두 표시되는 것을 볼 수 있습니다.
testshare에서 파일 및 폴더 생성을 테스트했습니다.

[ /]# cd /testshare/ [ testshare]# ls -l total 8 -rwxrwx---+ 1 SUNIL\testuser users 0 May 27 22:56 1.txt drwxrwx---+ 2 SUNIL\testuser users 6 May 27 22:56 test [ testshare]#
이제 다른 사용자로 로그인하고 있으며 commonshare만 표시됩니다.

commonshare에서 파일 생성.
[ commonshare]# ls -l total 8 drwxrwxrwx+ 2 SUNIL\testuser users 6 May 27 23:02 test drwxrwxrwx+ 2 SUNIL\sambauser users 6 May 27 23:07 test2 [ commonshare]#
이것이 Samba 4에서 공유를 생성하는 방법입니다.