본문 바로가기
카테고리 없음

[계정/권한 관리] freeIPA - IPA Server 이중화 구성하기(Replication)

by 이뫼장 2024. 2. 5.

이전글

2024.01.29 - [분류 전체보기] - [계정/권한 관리] freeIPA - IPA Server 설치하기

 


 

이전글에서도 이야기 했었지만 계정/권한을 관리할 서버(Client)에서 ipa server와 통신이 되지 않으면 ipa server를 통해 생성한 계정으로 로그인이 되지 않는다.

 

그렇기 때문에 ipa-server는 이중화가 필수라고 할 수 있다.

 

이번 글에서 복제(Slave)서버를 구성하는 방법에 대해 알아볼 예정이다.

 

 

0. 설치 환경

Replica 서버의 환경은 Master의 환경과 동일하다.

  • OS : RockyLinux 8.9
  • Kernel : 4.18.0-513.5.1.el8_9.x86_64 (default)
  • 인터넷이 되는 환경
  • FQDN으로 설정된 호스트 명 (이전글 참고)

 

1. 호스트 설정

이전글에서 설명했듯이 FreeIPA는 도메인 기반으로 동작하며, 그렇기 때문에 Master↔Slave 간 동기화도 도메인 기반으로 동작하게 된다.

 

이를 위해서 아래와 같이 /etc/hosts 파일에 Master, Slave의 도메인이 들어가있어야 한다. 

10.101.110.100	rocky-test-001.mystie.local
10.101.110.101	rocky-test-002.mystie.local
  • Master, Slave 서버 둘 다 설정해야 한다. 

 

2. IPA Client  설치/설정 하기

Slave 서버도 IPA Server 입장에서 Client 중 하나이기 때문에 Client를 먼저 설치 해주어야 한다. 

dnf install ipa-client

    

IPA Client Install

IPA Client도 Server처럼 맨 처음에 install을 해주어야 설정이 적용된다. 

ipa-client-install \
--unattended \
--principal=admin@MYSITE.LOCAL \
--domain=mysite.local \
--server=rocky-test-001.mysite.local \
--realm=MYSITE.LOCAL \
--hostname=rocky-test-002.mysite.local \
--password='yourpassword' \
--mkhomedir \
--no-ntp
  • --unattended : prompt를 출력하지 않는다.
  • --principal : IPA Realm에 가입하는데 사용할 계정
  • --server : IPA Server의 FQDN
  • --hostname : 자신의 FQDN
  • --password : IPA Realm에 가입하는데 사용할 계정의 팻흐워드
  • --mkhomedir : 신규 계정 생성 시 홈 디렉토리 자동생성 옵션
  • --no-ntp : ntp 자동 설정 제외

mkhomedir 옵션 pam에 적용하기

신규 생성한 계정으로 첫 로그인 시 home 디렉토리를 자동으로 생성해주는 옵션을 적용하기 위해서는 pam 설정에 mkhomedir 관련 설정을 해주어야 한다.

 

RockyLinux8 에서 mkhomedir 관련 옵션을 추가하는 방법은 아래와 같다.  

authconfig --enablemkhomedir --update

 

/etc/pam.d/system-auth 파일에서 확인하면 아래 설정이 추가되어 있다.

 

systemctl로 확인해보면 oddjobd도 실행되어 있다. 해당 데몬을 통해 관리하는 것으로 추정된다. 

 

3. IPA Replica Server를 ipaservers 그룹에 추가하기

IPA Replica 설치 전에 복제서버를 IPA Server에 등록해준다.

#IPA Server(Master)에서 실행
ipa hostgroup-add-member ipaservers --hosts rocky-test-002.mysite.local

 

[실행결과]

[root@rocky-test-001 home]# ipa hostgroup-add-member ipaservers --hosts rocky-test-002.mysite.local

  Host-group: ipaservers
  Description: IPA server hosts
  Member hosts: rocky-test-001.nicednb.local, rocky-test.nicednb.local
-------------------------
Number of members added 1
-------------------------

해당 실행 결과는 관리 Web페이지에서도 확인할 수 있다.

 

4. IPA Replication 패키지 설치 및 Install 설정

IPA Server 방화벽 해제

먼저 IPA Server(Master)에서 Replication 동작을 위한 방화벽을 해제해야 한다.

#IPA Master 서버에서
firewall-cmd --add-service=freeipa-replication --permanent
firewall-cmd --reload

 

IPA Server 패키지 설치

ipa-replication은 ipa-server에서 지원하는 모듈이다. 

 

이전글의 IPA Server 설치 방법을 참고하자. (모듈 enable → dnf 설치)

dnf module enable idm:DL1
dnf install ipa-server

 

다만, 모듈 enable 시 아래와 같이 에러가 발생한다면 idm:DL1 모듈을 reset 후 다시 enable 해주면 된다.

마지막 메타자료 만료확인(4:22:15 이전): 2024년 02월 05일 (월) 오전 11시 12분 07초.
종속성이 해결되었습니다.
이 작업은 'idm' 모듈을 'client' 스트림에서 ‘DL1' 스트림으로 전환합니다
오류: 구성 옵션 module_stream_switch를 통해 명시적으로 활성화하지 않는 한 활성화된 모듈 스트림을 전환 할 수 없습니다.
설치된 모든 내용을 모듈에서 제거하고 ‘dnf module reset <module_name>' 명령을 사용하여 모듈을 재설정하는 것이 좋습니다. 모듈을 재설정한 후 다른 스트림을 설치 할 수 있습니다.

 

모듈 reset 후 ipaserver 설치 방법

dnf module reset idm:DL1
dnf module enable idm:DL1
dnf install ipa-server

 

IPA Replication Server Firewall 해제

아래 단계에서 수행할 ipa-replica-install에서 마지막 단계에 자신의 서비스 연결 확인을 하는 동작이 있으므로 사전에 방화벽 해제를 등록한다.

#IPA Replication Server (slave)  서버에서 실행
firewall-cmd --permanent --add-service={http,https,dns,ntp,freeipa-ldap,freeipa-ldaps}
firewall-cmd --reload

 

IPA Replication Intallation

ipa-replica-install 방법도 이전글의 ipa-server-install 방법과 유사하다.

ipa-replica-install \
--unattended \
--admin-password='yourpassword' \
--domain=nicednb.local \
--server=rocky-test-001.mysite.local \
--realm=NICEDNB.LOCAL \
--hostname=rocky-test-002.mysite.local \
--principal=admin@MYSITE.LOCAL \
--no-host-dns \
--no-ntp
  • --principal : IPA Realm에 가입하는데 사용할 계정

각 옵션에 대한 설명은 이전글을 참고 하자.

 

[실행결과]

 

IdM CA 서비스 추가

FreeIPA 는 HTTP 및 Directory Service를 위해 SSL인증서를 사용한다.

IPA Replication 서브는 Master 서버의 Directory Service를 이용하는 것이기 때문에 CA구성이 필요하다.

 

IPA Replication 서버에 CA 없이 IPA Server를 설치 했기 때문에 아래와 같이 별도로 CA서비스 구성을 해주어야 한다.

#IPA Replication Server (slave)에서 실행
ipa-ca-install \
--unattended \
--no-host-dns \
--password='Nicednb123!!' \
--admin-password='Nicednb123!!'

 

5. Replication 상태 확인

kinit admin을 통해 로그인 후 ipa-replica-manage를 통해 상태 확인이 가능하다

kinit admin
ipa-replica-manage list --no-lookup

 

[실행결과]

[root@rocky-test-002 ~]# kinit admin
Password for admin@MYSITE.LOCAL: 
[root@rocky-test-002 ~]# ipa-replica-manage list --no-lookup
rocky-test-001.mysite.local: master
rocky-test-002.mysite.local: master

 

 

아래는 Master 서버에서 커맨드로 유저를 생성 후 Slave(Replica)서버에서 유저가 잘 확인되는지 테스트 하는 방법이다.

Master서버에서 유저 생성

ipa user-add tuser --first=firstname --last=lastname --shell=/bin/bash --password

 

[실행결과]

[root@rocky-test-001 home]# ipa user-add tuser --first=firstname --last=lastname --shell=/bin/bash --password
Password: 
Enter Password again to verify: 
------------------
Added user "tuser"
------------------
  User login: tuser
  First name: firstname
  Last name: lastname
  Full name: firstname lastname
  Display name: firstname lastname
  Initials: fl
  Home directory: /home/tuser
  GECOS: firstname lastname
  Login shell: /bin/bash
  Principal name: tuser@MYSITE.LOCAL
  Principal alias: tuser@MYSITE.LOCAL
  User password expiration: 20240205080829Z
  Email address: tuser@mysite.local
  UID: 1870000003
  GID: 1870000003
  Password: True
  Member of groups: ipausers
  Kerberos keys available: True

 

Slave(Replica)서버에서 유저 확인

ipa user-show tuser --all

 

[실행결과]

[root@rocky-test-002 ipa-slave-install-scripts]# ipa user-show tuser --all
  dn: uid=tuser,cn=users,cn=accounts,dc=mysite,dc=local
  User login: tuser
  First name: firstname
  Last name: lastname
  Full name: firstname lastname
  Display name: firstname lastname
  Initials: fl
  Home directory: /home/tuser
  GECOS: firstname lastname
  Login shell: /bin/bash
  Principal name: tuser@mysite.LOCAL
  Principal alias: tuser@mysite.LOCAL
  User password expiration: 20240205080829Z
  Email address: tuser@mysite.local
  UID: 1870000003
  GID: 1870000003
  Account disabled: False
  Preserved user: False
  Password: True
  Member of groups: ipausers
  Kerberos keys available: True
  ipantsecurityidentifier: S-1-5-21-2753058453-1442753-2717104110-1003
  ipauniqueid: bf848980-c3fd-11ee-aad9-0050569633be
  krbextradata: AAJ9l8Blcm9vdC9hZG1pbkBOSUNFRE5CLkxPQ0FMAA==
  krblastpwdchange: 20240205080829Z
  mepmanagedentry: cn=tuser,cn=groups,cn=accounts,dc=mysite,dc=local
  objectclass: top, person, organizationalperson, inetorgperson, inetuser, posixaccount, krbprincipalaux, krbticketpolicyaux, ipaobject, ipasshuser, ipaSshGroupOfPubKeys, mepOriginEntry, ipantuserattrs

 

 

 

마치며..

여기까지 했으면 IPA-Server 및 이중화까지 완료된 것이다. 

 

Replica 서버는 추가적으로 더 생성이 가능하다 (방법은 위와 동일하다)

환경에 맞춰서 안정성을 고려하여 추가적으로 구성하면된다.

 

다음에는 Client 서버 구성 방법에 대해 알아볼 예정이다.