1. 개요
이 문서는 CentOS 7을 기준으로 작성된 OpenLDAP 서버 설치 및 초기 구성 절차를 다룬다.
Ubuntu나 Rocky, AlmaLinux 계열에서도 거의 동일하게 적용할 수 있으며,
서비스명(slapd)과 설정 경로(/etc/ldap/ 또는 /etc/openldap/)만 다르다.
⚠️ 주의:
본문에 등장하는 IP, 도메인명, hostname, 계정명은 모두 예시다.
실제 환경에서는 반드시 조직의 네트워크 정책과 보안 규칙에 맞게 변경해야 한다.
2. OpenLDAP 설치
2.1 패키지 설치
CentOS 7에서는 기본 저장소에 포함되어 있다.
# yum install -y openldap compat-openldap openldap-clients openldap-servers openldap-servers-sql openldap-devel
Ubuntu 계열이라면 다음과 같이 설치한다.
# apt install slapd ldap-utils
2.2 서비스 등록 및 실행 확인
# systemctl enable slapd
# systemctl start slapd
# systemctl status slapd
LDAP 서비스는 기본적으로 TCP 389 포트를 사용한다.
포트 확인:
# netstat -tulnp | grep 389
3. 관리자 비밀번호 생성
OpenLDAP 관리용 계정(cn=manager)의 비밀번호를 생성한다.
# slappasswd
New password:
Re-enter new password:
{SSHA}wL2YjR1iZ2VfK3s9bHbF4vAozLzLzFqC
결과로 출력된 {SSHA}로 시작하는 문자열을 따로 보관한다.
이 값이 manager 계정의 암호 해시로 사용된다.
4. 초기 DB 설정 (LDIF 방식)
OpenLDAP 2.4 이후부터는 /etc/openldap/slapd.d/ 내 설정 파일을 직접 수정하지 않고,
LDIF 파일을 만들어 ldapmodify 명령으로 적용해야 한다.
4.1 LDIF 디렉토리 생성
# mkdir /etc/openldap/ldif
4.2 데이터베이스 설정 파일 작성
(/etc/openldap/ldif/db.ldif)
dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcSuffix
olcSuffix: dc=example,dc=com
dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcRootDN
olcRootDN: cn=manager,dc=example,dc=com
dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcRootPW
olcRootPW: {SSHA}wL2YjR1iZ2VfK3s9bHbF4vAozLzLzFqC
4.3 적용
# ldapmodify -Y EXTERNAL -H ldapi:/// -f /etc/openldap/ldif/db.ldif
성공 시 출력 예:
modifying entry "olcDatabase={2}hdb,cn=config"
5. 모니터 계정 접근 설정
OpenLDAP의 모니터 데이터베이스(cn=monitor)는 root 사용자만 접근 가능하게 변경한다./etc/openldap/ldif/monitor.ldif 작성:
dn: olcDatabase={1}monitor,cn=config
changetype: modify
replace: olcAccess
olcAccess: {0}to *
by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" read
by dn.base="cn=manager,dc=example,dc=com" read
by * none
적용:
# ldapmodify -Y EXTERNAL -H ldapi:/// -f /etc/openldap/ldif/monitor.ldif
6. 스키마(Schema) 적용
OpenLDAP은 기본 제공 스키마 외에 추가 속성을 확장할 수 있다.
기본적으로 다음 세 가지를 반드시 추가한다.
# ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/cosine.ldif
# ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/nis.ldif
# ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/inetorgperson.ldif
7. 초기 도메인 구조 생성
조직 도메인을 example.com으로 가정했을 때,
다음과 같이 기본 구조를 만든다.
/etc/openldap/ldif/base.ldif:
dn: dc=example,dc=com
objectClass: top
objectClass: domain
dc: example
dn: cn=manager,dc=example,dc=com
objectClass: organizationalRole
cn: manager
description: LDAP Manager
dn: ou=People,dc=example,dc=com
objectClass: organizationalUnit
ou: People
dn: ou=Group,dc=example,dc=com
objectClass: organizationalUnit
ou: Group
적용:
# ldapadd -x -W -D "cn=manager,dc=example,dc=com" -f /etc/openldap/ldif/base.ldif
성공 메시지 예시:
adding new entry "dc=example,dc=com"
adding new entry "cn=manager,dc=example,dc=com"
adding new entry "ou=People,dc=example,dc=com"
adding new entry "ou=Group,dc=example,dc=com"
8. 설정 파일 수정 시 유의사항
/etc/openldap/slapd.d내부 파일을 직접 수정하지 말 것.
→ 잘못 수정 시 slapd 재시작 불가.- 수정은 항상 별도 LDIF 파일을 생성 → ldapmodify 명령으로 반영해야 한다.
slapd.conf방식은 2.4 이후 완전히 폐기되었다.- 모든 설정 파일은 root 권한으로만 접근 가능하게 제한 (
chmod 600) 한다.
9. 기본 테스트
# ldapsearch -x -LLL -b "dc=example,dc=com"
예상 출력:
dn: dc=example,dc=com
objectClass: top
objectClass: domain
dc: example
정상적으로 출력된다면 초기 구성은 완료된 것이다.
10. 다음 단계 예고
다음 글에서는 클라이언트 서버(Linux)에서 LDAP 인증을 사용하는 방법을 다룬다.authconfig, nslcd, sssd를 이용해 SSH 로그인, sudo/su 통합 인증을 구현하고
그룹별 접근권한을 LDAP 정책과 연동하는 과정을 설명한다.
ⓒ 2025 엉뚱한 녀석의 블로그 [quirky guy's Blog]. All rights reserved. Unauthorized copying or redistribution of the text and images is prohibited. When sharing, please include the original source link.
🛠 마지막 수정일: 2025.10.25
답글 남기기
댓글을 달기 위해서는 로그인해야합니다.