Cài đặt và cấu hình FreeIPA Server trên Centos 7

Tác giả: 27/05/2025

FreeIPA Server là một hệ thống quản lý danh tính và xác thực (Identity and Authentication Management) mã nguồn mở, chủ yếu được sử dụng trên các hệ thống Linux, đặc biệt là Red HatCentOS/Rocky/AlmaLinux.

FreeIPA bao gồm những thành phần nào?

FreeIPA tích hợp nhiều công nghệ mã nguồn mở để cung cấp một giải pháp quản lý tập trung:

  • LDAP server (389 Directory Server): Lưu trữ thông tin người dùng, nhóm, máy tính…

  • Kerberos: Cung cấp xác thực mạnh, hỗ trợ Single Sign-On (SSO).

  • DNS server (tùy chọn): Quản lý tên miền nội bộ.

  • NTP server: Đồng bộ thời gian cho hệ thống.

  • Dogtag (Certificate System): Cấp phát và quản lý chứng chỉ số (CA).

  • SSSD (System Security Services Daemon): Giao tiếp giữa client và FreeIPA server.

  • Web UI + CLI: Giao diện quản trị và dòng lệnh.

FreeIPA dùng để làm gì?

  • Quản lý người dùng, nhóm, quyền truy cập trên toàn bộ hệ thống một cách tập trung.

  • Xác thực người dùng bằng Kerberos (có thể kết hợp LDAP).

  • SSO (Single Sign-On): Người dùng chỉ cần đăng nhập một lần để truy cập các dịch vụ khác.

  • Tích hợp với hệ thống DNS để quản lý bản ghi tên miền nội bộ.

  • Cung cấp chứng chỉ SSL nội bộ cho các hệ thống (CA nội bộ).

  • Thay thế Active Directory trong môi trường Linux thuần.

Ví dụ sử dụng FreeIPA trong thực tế

  • Một công ty có nhiều máy chủ Linux muốn quản lý quyền truy cập người dùng tập trung, có thể cài FreeIPA Server và kết nối tất cả các máy chủ khác như IPA Clients.

  • Khi một nhân viên nghỉ việc, chỉ cần xóa tài khoản khỏi FreeIPA Server là quyền truy cập bị thu hồi trên toàn hệ thống.

Yêu cầu hệ thống:

Thành phần Yêu cầu
OS CentOS 7 (Minimal hoặc Full)
RAM Tối thiểu 2 GB (khuyến nghị 4 GB+)
CPU 2 vCPU trở lên
Hostname Đặt FQDN (ví dụ: ipa.example.com)
SELinux Cho phép (enforcing)
Firewalld Đang chạy (firewall active)
DNS Nên cấu hình tĩnh / nội bộ

Hướng dẫn cài đặt

Bước 1: Đặt hostname và ánh xạ IP public

Giả sử bạn có IP public: 103.170.122.37
Và bạn muốn hostname là: ipa.cloud365.vn

hostnamectl set-hostname ipa.cloud365.vn
echo "103.170.122.37 ipa.cloud365.vn" >> /etc/hosts 

Quan trọng: FreeIPA bắt buộc hostname phải là FQDN (có dấu chấm), không được là IP.
Bước 2: Bật firewalld nếu chưa có thì cài thêm
sudo yum install firewalld -y
sudo systemctl enable firewalld
sudo systemctl start firewalld
Bước 3: Thiết lập các port cần thiết
firewall-cmd --permanent --add-port={80/tcp,443/tcp,389/tcp,636/tcp,88/tcp,464/tcp,53/tcp,88/udp,464/udp,53/udp,123/udp}
sudo firewall-cmd --reload
Bước 4: Cấu hình IPv4 và IPv6
vi /etc/cloud/templates/hosts.redhat.tmpl
Tìm dòng ipv4:
127.0.0.1 {{fqdn}} {{hostname}}
thay 127.0.0.1 thành IPv4(103.170.122.37) của server:
103.170.122.37 {{fqdn}} {{hostname}}
Tìm dòng ipv6:
# The following lines are desirable for IPv6 capable hosts
::1 {{fqdn}} {{hostname}}
thay thế ::1 bằng ipv6:
fa:16:3e:6d:62:40 {{fqdn}} {{hostname}}
Cấu hình bật ipv6:
vi /etc/sysctl.conf
Chỉnh 1 thành 0 2 dòng bên dưới để bật ipv6
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
Áp dụng cho máy chủ
sudo sysctl -p
Bước 5: Cấu hình bộ tạo số ngẫu nhiên
Thiết lập FreeIPA yêu cầu rất nhiều dữ liệu ngẫu nhiên cho các hoạt động mã hóa. Theo mặc định, máy ảo sẽ bị cạn kiệt random data hoặc entropy rất nhanh. Để giải quyết vấn đề này, bạn sẽ sử dụng rngd, một phần mềm khởi tạo số ngẫu nhiên. rngd hoạt động bằng cách lấy dữ liệu từ các thiết bị phần cứng được kết nối với server và đưa nó vào bộ tạo số ngẫu nhiên của kernel.
Cài đặt rngd:
yum install rng-tools
systemctl start rngd
systemctl enable rngd
systemctl status rngd
Bước 6: Cấu hình server FreeIPA
yum install bind-utils ipa-server -y
ipa-server-install
[root@ipa /]# ipa-server-install

The log file for this installation can be found in /var/log/ipaserver-install.log
==============================================================================
This program will set up the IPA Server.

This includes:
* Configure a stand-alone CA (dogtag) for certificate management
* Configure the Network Time Daemon (ntpd)
* Create and configure an instance of Directory Server
* Create and configure a Kerberos Key Distribution Center (KDC)
* Configure Apache (httpd)
* Configure the KDC to enable PKINIT

To accept the default shown in brackets, press the Enter key.

WARNING: conflicting time&date synchronization service ‘chronyd’ will be disabled
in favor of ntpd

Do you want to configure integrated DNS (BIND)? [no]: no

Enter the fully qualified domain name of the computer
on which you’re setting up server software. Using the form
<hostname>.<domainname>
Example: master.example.com.

Server host name [ipa.cloud365.vn]: ipa.cloud365.vn

The domain name has been determined based on the host name.

Please confirm the domain name [cloud365.vn]: ipa.cloud365.vn

The kerberos protocol requires a Realm name to be defined.
This is typically the domain name converted to uppercase.

Please provide a realm name [IPA.CLOUD365.VN]: ipa.cloud365.vn
An upper-case realm name is required.
Do you want to use IPA.CLOUD365.VN as realm name? [yes]: yes

Certain directory server operations require an administrative user.
This user is referred to as the Directory Manager and has full access
to the Directory for system management tasks and will be added to the
instance of directory server created for IPA.
The password must be at least 8 characters long.

Directory Manager password:
Password (confirm):

The IPA server requires an administrative user, named ‘admin’.
This user is a regular system account used for IPA server administration.

IPA admin password:
Password (confirm):

The IPA Master Server will be configured with:
Hostname: ipa.cloud365.vn
IP address(es): 103.170.122.37
Domain name: ipa.cloud365.vn
Realm name: IPA.CLOUD365.VN

Continue to configure the system with these values? [no]: yes

The following operations may take some minutes to complete.
Please wait until the prompt is returned.

………

Setup complete

Next steps:
1. You must make sure these network ports are open:
TCP Ports:
* 80, 443: HTTP/HTTPS
* 389, 636: LDAP/LDAPS
* 88, 464: kerberos
UDP Ports:
* 88, 464: kerberos
* 123: ntp

2. You can now obtain a kerberos ticket using the command: ‘kinit admin’
This ticket will allow you to use the IPA tools (e.g., ipa user-add)
and the web user interface.

Be sure to back up the CA certificates stored in /root/cacert.p12
These files are required to create replicas. The password for these
files is the Directory Manager password

Bước 7: Truy cập vào đường dẫn web
https://ipa.cloud365.vn
User: admin
Password: Khi cấu hình đặt
Nếu quên dùng lệnh kinit admin để đặt lại password.
Tới đây thì đã hoàn thành xong bước cài đặt FreeIPA Server.