서버 설정 · 7 min read · Oct 06, 2025
Debian Etch에서 Mandriva Directory Server - 페이지 2
5 SAMBA
5.1 기본 구성
먼저 SAMBA를 중지합니다.
/etc/init.d/samba stop예제 SAMBA 구성 파일을 SAMBA 디렉토리로 복사합니다 …
cp /usr/share/doc/python-mmc-base/contrib/samba/smb.conf /etc/samba/… 그리고 필요에 맞게 조정합니다.
vi /etc/samba/smb.conf[global] 섹션에 다음 값을 설정합니다:
workgroup = EXAMPLE
netbiosname = PDC-SRV-EXAMPLE
ldap admin dn = cn=admin,dc=example,dc=com
ldap suffix = dc=example,dc=com
logon path = \%N\profiles\%U
[global] 섹션에 다음 줄을 추가합니다:
preferred master = yes
os level = 65
wins support = yes
timeserver = yes
socket options = SO_KEEPALIVE IPTOS_LOWDELAY SO_SNDBUF=8192 SO_RCVBUF=8192
logon drive = H:
passwd program = /usr/sbin/smbldap-passwd -u %u
passwd chat = “Changing password for\nNew password“ %n\n “Retype new password“ %n\n
add user script = /usr/sbin/smbldap-useradd -m “%u”
add user to group script = /usr/sbin/smbldap-groupmod -m “%u” “%g”
set primary group script = /usr/sbin/smbldap-usermod -g “%g” “%u”
add group script = /usr/sbin/ambldap-groupadd -p “%g”
delete user script = /usr/sbin/smbldap-userdel “%u”
delete user from group script = /usr/sbin/smbldap-groupmod -x “%u” “%g”
delete group script = /usr/sbin/smbldap-groupdel “%g”
obey pam restrictions = no
ldap idmap suffix = ou=Users
ldap delete dn = yes
security = user
[homes] 섹션에 다음 줄을 추가합니다:
hide files = /Maildir/[printers] 및 [print$] 섹션에서 다음 줄을 제거합니다:
printer admin = root,@lpadmin[print$] 섹션에 다음 값을 설정합니다:
write list = Administrator,root,@lpadmin
[profiles] 섹션에 다음 줄을 추가합니다:
hide files = /desktop.ini/ntuser.ini/NTUSER.*/[archives] 섹션에 다음 값을 설정합니다:
path = /home/samba/archives
이 시점에서 SAMBA 구성 파일은 다음과 같아야 합니다:
[global]
workgroup = EXAMPLE
netbiosname = PDC-SRV-EXAMPLE
preferred master = yes
os level = 65
wins support = yes
enable privileges = yes
timeserver = yes
socket options = SO_KEEPALIVE IPTOS_LOWDELAY SO_SNDBUF=8192 SO_RCVBUF=8192
log level = 3
null passwords = yes
security = user
# unix charset = ISO8859-1
name resolve order = bcast host
domain logons = yes
domain master = yes
printing = cups
printcap name = cups
logon path = \\%N\profiles\%U
logon script = logon.bat
logon drive = H:
map acl inherit = yes
nt acl support = yes
passdb backend = ldapsam:ldap://127.0.0.1/
obey pam restrictions = no
ldap admin dn = cn=admin,dc=example,dc=com
ldap suffix = dc=example,dc=com
ldap group suffix = ou=Groups
ldap user suffix = ou=Users
ldap machine suffix = ou=Computers
ldap idmap suffix = ou=Users
ldap passwd sync = yes
ldap delete dn = yes
passwd program = /usr/sbin/smbldap-passwd -u %u
passwd chat = "Changing password for*\nNew password*" %n\n "*Retype new password*" %n\n
add user script = /usr/sbin/smbldap-useradd -m "%u"
add user to group script = /usr/sbin/smbldap-groupmod -m "%u" "%g"
set primary group script = /usr/sbin/smbldap-usermod -g "%g" "%u"
add group script = /usr/sbin/ambldap-groupadd -p "%g"
add machine script = /usr/lib/mmc/add_machine_script '%u'
delete user script = /usr/sbin/smbldap-userdel "%u"
delete user from group script = /usr/sbin/smbldap-groupmod -x "%u" "%g"
delete group script = /usr/sbin/smbldap-groupdel "%g"
[homes]
comment = Home directories
browseable = no
writeable = yes
create mask = 0700
directory mask = 0700
hide files = /Maildir/
[public]
comment = Public share
path = /home/samba/shares/public
browseable = yes
public = yes
writeable = yes
[archives]
comment = Backup share
path = /home/samba/archives
browseable = yes
public = no
writeable = no
[printers]
comment = Printers
path = /tmp
browseable = no
public = yes
guest ok = yes
writeable = no
printable = yes
[print$]
comment = Drivers
path = /var/lib/samba/printers
browseable = yes
guest ok = yes
read only = yes
write list = Administrator,root,@lpadmin
[netlogon]
path = /home/samba/netlogon
public = no
writeable = no
browseable = no
[profiles]
path = /home/samba/profiles
writeable = yes
create mask = 0700
directory mask = 0700
browseable = no
hide files = /desktop.ini/ntuser.ini/NTUSER.*/
[partage]
comment = aucun
path = /home/samba/partage
browseable = yes
public = no
writeable = yes모든 것이 잘 진행되었다면, 명령어 …
testparm…은 오류가 없어야 합니다.
이제 SAMBA가 LDAP에 쓸 수 있는 필요한 자격 증명을 제공합니다.
smbpasswd -w %ldap_admin_password%예:
smbpasswd -w howtoforge출력은 다음과 같아야 합니다:
Setting stored password for "cn=admin,dc=example,dc=com" in secrets.tdb다음으로 작업 그룹에 대한 SID를 생성해야 합니다.
net getlocalsid %your_workgroup%예:
net getlocalsid EXAMPLE출력은 다음과 같아야 합니다 - 메모해 두세요, 잠시 후에 필요합니다:
SID for domain EXAMPLE is: S-1-5-21-3159899821-123882392-54881133SID가 실제로 LDAP에 기록되었는지 확인합니다.
slapcat | grep sambaDomainName출력은 다음과 같아야 합니다:
dn: sambaDomainName=EXAMPLE,dc=example,dc=com
sambaDomainName: EXAMPLE이제 SAMBA를 시작합니다.
/etc/init.d/samba start5.2 LDAP 디렉토리
먼저 smbldap-tools 구성 파일을 생성해야 합니다 - LDAP 서버와 통신하는 방법을 정의합니다.
vi /etc/smbldap-tools/smbldap_bind.conf내용은 다음과 같아야 합니다:
slaveDN="cn=admin,dc=example,dc=com"
slavePw="howtoforge"
masterDN="cn=admin,dc=example,dc=com"
masterPw="howtoforge"이제 주요 구성 파일을 생성합니다.
vi /etc/smbldap-tools/smbldap.conf내용은 다음과 같아야 합니다 (SID를 자신의 것으로 교체하세요!):
SID="S-1-5-21-3159899821-123882392-54881133"
sambaDomain="EXAMPLE"
ldapTLS="0"
suffix="dc=example,dc=com"
usersdn="ou=Users,${suffix}"
computersdn="ou=Computers,${suffix}"
groupsdn="ou=Groups,${suffix}"
idmapdn="ou=Idmap,${suffix}"
sambaUnixIdPooldn="sambaDomainName=EXAMPLE,${suffix}"
scope="sub"
hash_encrypt="SSHA"
userLoginShell="/bin/bash"
userHome="/home/%U"
userHomeDirectoryMode="700"
userGecos="System User"
defaultUserGid="513"
defaultComputerGid="515"
skeletonDir="/etc/skel"
defaultMaxPasswordAge="45"
userSmbHome="\\PDC-SRV-EXAMPLE\%U"
userProfile="\\PDC-SRV-EXAMPLE\profiles\%U"
userHomeDrive="H:"
userScript="logon.bat"
mailDomain="example.com"
smbpasswd="/usr/bin/smbpasswd"이제 LDAP 디렉토리를 채울 시간입니다. 이것은 도메인 관리자 계정(Administrator)도 생성합니다.
smbldap-populate -m 512 -a Administrator참고: 도메인 관리자 계정의 비밀번호를 입력하라는 메시지가 표시됩니다.
그 후 이 계정의 uid-number를 수정해야 합니다 - 그렇지 않으면 이 계정을 사용하여 메일 서버를 사용할 수 없습니다. 추가로 이 계정을 “Domain Users” 그룹에 추가합니다:
smbldap-usermod -u 3000 -G "Domain Users" Administrator5.3 NSS LDAP 구성
이 단계에서는 시스템이 사용자 및 그룹 목록을 가져오기 위해 LDAP 디렉토리를 사용하도록 구성합니다.
nsswitch 구성을 편집합니다.
vi /etc/nsswitch.conf내용은 다음과 같아야 합니다:
# /etc/nsswitch.conf
#
# GNU Name Service Switch 기능의 예제 구성.
# `glibc-doc' 및 `info' 패키지가 설치되어 있으면, 다음을 시도하세요:
# `info libc "Name Service Switch"' 이 파일에 대한 정보.
passwd: compat ldap
group: compat ldap
shadow: compat ldap
hosts: files dns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis5.4 SAMBA 디렉토리
SAMBA 서버에 필요한 디렉토리를 생성합니다 …
mkdir -p /home/samba/shares/public/
mkdir /home/samba/netlogon/
mkdir /home/samba/profiles/
mkdir /home/samba/partage/
mkdir /home/samba/archives/… 소유권을 변경하고 권한을 조정합니다.
chown -R :"Domain Users" /home/samba/
chmod 777 /var/spool/samba/ /home/samba/shares/public/
chmod 755 /home/samba/netlogon/
chmod 770 /home/samba/profiles/ /home/samba/partage/
chmod 700 /home/samba/archives/6 PAM LDAP 구성
이 단계에서는 PAM에 LDAP 지원을 추가합니다.
vi /etc/pam.d/common-account내용은 다음과 같아야 합니다:
#
# /etc/pam.d/common-account - 모든 서비스에 공통적인 인증 설정
#
# 이 파일은 다른 서비스별 PAM 구성 파일에서 포함되며,
# 시스템에서 사용할 중앙 접근 정책을 정의하는 인증 모듈 목록을 포함해야 합니다. 기본적으로는
# /etc/shadow에서 만료된 계정의 사용자에게 서비스만 거부합니다.
#
account required pam_unix.so
account sufficient pam_ldap.sovi /etc/pam.d/common-auth내용은 다음과 같아야 합니다:
#
# /etc/pam.d/common-auth - 모든 서비스에 공통적인 인증 설정
#
# 이 파일은 다른 서비스별 PAM 구성 파일에서 포함되며,
# 시스템에서 사용할 중앙 인증 체계를 정의하는 인증 모듈 목록을 포함해야 합니다
# (예: /etc/shadow, LDAP, Kerberos 등). 기본적으로는
# 전통적인 Unix 인증 메커니즘을 사용합니다.
#
auth sufficient pam_unix.so nullok_secure
auth sufficient pam_ldap.so use_first_pass
auth required pam_deny.sovi /etc/pam.d/common-password내용은 다음과 같아야 합니다:
#
# /etc/pam.d/common-password - 모든 서비스에 공통적인 비밀번호 관련 모듈
#
# 이 파일은 다른 서비스별 PAM 구성 파일에서 포함되며,
# 사용자 비밀번호를 변경하는 데 사용되는 모듈 목록을 포함해야 합니다. 기본적으로 pam_unix
# "nullok" 옵션은 사용자가 빈 비밀번호를 변경할 수 있도록 허용하며, 그렇지 않으면
# 빈 비밀번호는 잠긴 계정으로 간주됩니다.
#
# (모듈 이름 뒤에 `md5'를 추가하여 MD5 비밀번호를 활성화)
#
# "obscure" 옵션은 이전의 `OBSCURE_CHECKS_ENAB' 옵션을 대체합니다.
# 또한 "min" 및 "max" 옵션은 새 비밀번호의 길이를 강제합니다.
password sufficient pam_unix.so nullok obscure min=4 max=8 md5
password sufficient pam_ldap.so use_first_pass use_authtok
password required pam_deny.so
# 비밀번호에 대한 대체 강도 검사. 이는
# libpam-cracklib 패키지가 설치되어 있어야 합니다.
# 위의 비밀번호 줄을 주석 처리하고
# 다음 두 줄의 주석을 해제하여 사용해야 합니다.
# ( `OBSCURE_CHECKS_ENAB', `CRACKLIB_DICTPATH'를 대체)
#
# password required pam_cracklib.so retry=3 minlen=6 difok=3
# password required pam_unix.so use_authtok nullok md5vi /etc/pam.d/common-session내용은 다음과 같아야 합니다:
#
# /etc/pam.d/common-session - 모든 서비스에 공통적인 세션 관련 모듈
#
# 이 파일은 다른 서비스별 PAM 구성 파일에서 포함되며,
# 모든 종류의 세션(대화형 및 비대화형)의 시작 및 종료 시 수행할 작업을 정의하는 모듈 목록을 포함해야 합니다.
# 기본적으로 pam_unix입니다.
#
session required pam_unix.so
session optional pam_ldap.so그 후 시스템을 재부팅합니다.
reboot시스템이 다시 시작되면, “Domain Admins” 그룹에 도메인에 기계를 추가할 권한을 부여합니다.
net -U Administrator rpc rights grant 'DOMAIN\Domain Admins' SeMachineAccountPrivilege7 메일을 위한 SSL
먼저 필요한 정보로 구성 파일을 준비합니다.
vi /etc/ssl/mail.cnf다음 내용을 추가합니다:
[ req ]
default_bits = 2048
default_keyfile = privkey.pem
distinguished_name = req_distinguished_name
prompt = no
string_mask = nombstr
x509_extensions = server_cert
[ req_distinguished_name ]
countryName = DE
stateOrProvinceName = Niedersachsen
localityName = Lueneburg
organizationName = Projektfarm GmbH
organizationalUnitName = IT
commonName = server1.example.com
emailAddress = [email protected]
[ server_cert ]
basicConstraints = critical, CA:FALSE
subjectKeyIdentifier = hash
keyUsage = digitalSignature, keyEncipherment
extendedKeyUsage = serverAuth, clientAuth
nsCertType = server
nsComment = "mailserver"이제 SSL 인증서를 생성합니다 …
openssl req -x509 -new -config /etc/ssl/mail.cnf -out /etc/ssl/certs/mail.pem -keyout /etc/ssl/private/mail.key -days 365 -nodes -batch… 그리고 키에 대한 권한을 조정하여 root만 읽을 수 있도록 합니다.
chmod 600 /etc/ssl/private/mail.key새 게시물을 받은 편지함에서 받기
스팸은 없습니다. 언제든지 구독 해지 가능합니다.