In my last article I shared the steps to restrict root user to access and modify respective files/directories and steps to perform SSH local and remote port forwarding in Linux. Now in this article I will explain you about FreeIPA server and step by step tutorial guide to setup an IPA server and IPA client on CentOS 7 Linux node.
FreeIPA like Microsoft’s Active Directory, is an open source project, sponsored by Red Hat, which makes it easy to manage the identity, policy, and audit for Linux-based servers. IPA stands for Identity, Policy and Authentication.
- IPA is a collection of very useful services that make IPA the Linux equivalent for Active Directory in a Microsoft environment.
- It includes LDAP, the Lightweight Directory Access Protocol, which allows users to be stored in a hierarchical or replicated database.
- It includes Kerberos, which allows for advanced authentication tickets that make sure that no passwords need to be sent in plain text to the LDAP server.
- It includes DNS, as well, which helps storing all the information that Kerberos needs in the DNS database.
- And it includes a Certificate Authority. A Certificate Authority that helps you generating PKI certificates for use with, for example, AODV mail server or an Apache web server.
- Overall, it has Tomcat. Tomcat, which is offering web access in an efficient way to manage all of these.
If you look at Linux without IPA, managing LDAP and Kerberos and DNS and CA can be very challenging. If you are running IPA on top of Linux, you just get an easy to use web interface.
IPA follows the client-server-based model. This means that in each of the servers, there is an IPA client that is installed and connected to the IPA server.
Whenever a user wants to access the server, the IPA client connects to the IPA server to check if the user has the required permissions to do so. If proper permissions are present, the access is given; otherwise, it is denied.
For the demonstration of this article I am using CentOS 7.4. Below are the node details I will be using for demonstrating this article
|OS||CentOS 7||CentOS 7||CentOS 7|
|FreeIPA||IPA Server||IPA Client||IPA Client|
Install FreeIPA Server
First of all let us search the package name required for configuring FreeIPA server.
[root@node1 ~]# yum search ipa-server Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: ftp.iitm.ac.in * extras: centos.mirrors.estointernet.in * updates: centos.mirrors.estointernet.in ================================================= N/S matched: ipa-server ================================================= ipa-server.x86_64 : The IPA authentication server ipa-server-common.noarch : Common files used by IPA server ipa-server-dns.noarch : IPA integrated DNS server with support for automatic DNSSEC signing ipa-server-trust-ad.x86_64 : Virtual package to install packages required for Active Directory trusts Name and summary matches only, use "search all" for everything.
So now we know we need
ipa-server-dns rpm to set up our FreeIPA server.
[root@node1 ~]# yum install ipa-server.x86_64 ipa-server-dns.noarch -y
Once installed, update your hosts file with the FQDN names of all the nodes in your setup. Without this the FreeIPA server configuration will not work.
[root@node1 ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 10.0.2.31 node2.example.com node2 10.0.2.30 node1.example.com node1 10.0.2.32 node3.example.com node3
Execute the below command to start the FreeIPA central identity server configuration. This command will also setup DNS server along with IPA server.
[root@node1 ~]# ipa-server-install --setup-dns --allow-zone-overlap 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 DNS (bind) * 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 Enter the fully qualified domain name of the computer on which you're setting up server software. Using the form . Example: master.example.com. Server host name [node1.example.com]: Warning: skipping DNS resolution of host node1.example.com The domain name has been determined based on the host name. Please confirm the domain name [example.com]: The kerberos protocol requires a Realm name to be defined. This is typically the domain name converted to uppercase. Please provide a realm name [EXAMPLE.COM]: 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): Checking DNS domain example.com., please wait ... Do you want to configure DNS forwarders? [yes]: yes Following DNS servers are configured in /etc/resolv.conf: 192.168.0.1, 220.127.116.11 Do you want to configure these servers as DNS forwarders? [yes]: yes All DNS servers from /etc/resolv.conf were added. You can enter additional addresses now: Enter an IP address for a DNS forwarder, or press Enter to skip: Checking DNS forwarders, please wait ... Do you want to search for missing reverse zones? [yes]: Do you want to create reverse zone for IP 10.0.2.30 [yes]: Please specify the reverse zone name [2.0.10.in-addr.arpa.]: Using reverse zone(s) 2.0.10.in-addr.arpa. The IPA Master Server will be configured with: Hostname: node1.example.com IP address(es): 10.0.2.30 Domain name: example.com Realm name: EXAMPLE.COM BIND DNS server will be configured to serve IPA domain with: Forwarders: 192.168.0.1, 18.104.22.168 Forward policy: only Reverse zone(s): 2.0.10.in-addr.arpa. 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. Configuring NTP daemon (ntpd) [1/4]: stopping ntpd [2/4]: writing configuration [3/4]: configuring ntpd to start on boot [4/4]: starting ntpd Done configuring NTP daemon (ntpd). Configuring directory server (dirsrv). Estimated time: 30 seconds [1/44]: creating directory server instance [2/44]: enabling ldapi [3/44]: configure autobind for root [4/44]: stopping directory server [5/44]: updating configuration in dse.ldif [6/44]: starting directory server [7/44]: adding default schema [8/44]: enabling memberof plugin [9/44]: enabling winsync plugin [10/44]: configuring replication version plugin [11/44]: enabling IPA enrollment plugin [12/44]: configuring uniqueness plugin [13/44]: configuring uuid plugin [14/44]: configuring modrdn plugin [15/44]: configuring DNS plugin [16/44]: enabling entryUSN plugin [17/44]: configuring lockout plugin [18/44]: configuring topology plugin [19/44]: creating indices [20/44]: enabling referential integrity plugin [21/44]: configuring certmap.conf [22/44]: configure new location for managed entries [23/44]: configure dirsrv ccache [24/44]: enabling SASL mapping fallback [25/44]: restarting directory server [26/44]: adding sasl mappings to the directory [27/44]: adding default layout [28/44]: adding delegation layout [29/44]: creating container for managed entries [30/44]: configuring user private groups [31/44]: configuring netgroups from hostgroups [32/44]: creating default Sudo bind user [33/44]: creating default Auto Member layout [34/44]: adding range check plugin [35/44]: creating default HBAC rule allow_all [36/44]: adding entries for topology management [37/44]: initializing group membership [38/44]: adding master entry [39/44]: initializing domain level [40/44]: configuring Posix uid/gid generation [41/44]: adding replication acis [42/44]: activating sidgen plugin [43/44]: activating extdom plugin [44/44]: configuring directory to start on boot Done configuring directory server (dirsrv). Configuring Kerberos KDC (krb5kdc) [1/10]: adding kerberos container to the directory [2/10]: configuring KDC [3/10]: initialize kerberos container [4/10]: adding default ACIs [5/10]: creating a keytab for the directory [6/10]: creating a keytab for the machine [7/10]: adding the password extension to the directory [8/10]: creating anonymous principal [9/10]: starting the KDC [10/10]: configuring KDC to start on boot Done configuring Kerberos KDC (krb5kdc). Configuring kadmin [1/2]: starting kadmin [2/2]: configuring kadmin to start on boot Done configuring kadmin. Configuring ipa-custodia [1/5]: Making sure custodia container exists [2/5]: Generating ipa-custodia config file [3/5]: Generating ipa-custodia keys [4/5]: starting ipa-custodia [5/5]: configuring ipa-custodia to start on boot Done configuring ipa-custodia. Configuring certificate server (pki-tomcatd). Estimated time: 3 minutes [1/28]: configuring certificate server instance [2/28]: exporting Dogtag certificate store pin [3/28]: stopping certificate server instance to update CS.cfg [4/28]: backing up CS.cfg [5/28]: disabling nonces [6/28]: set up CRL publishing [7/28]: enable PKIX certificate path discovery and validation [8/28]: starting certificate server instance [9/28]: configure certmonger for renewals [10/28]: requesting RA certificate from CA [11/28]: setting audit signing renewal to 2 years [12/28]: restarting certificate server [13/28]: publishing the CA certificate [14/28]: adding RA agent as a trusted user [15/28]: authorizing RA to modify profiles [16/28]: authorizing RA to manage lightweight CAs [17/28]: Ensure lightweight CAs container exists [18/28]: configure certificate renewals [19/28]: configure Server-Cert certificate renewal [20/28]: Configure HTTP to proxy connections [21/28]: restarting certificate server [22/28]: updating IPA configuration [23/28]: enabling CA instance [24/28]: migrating certificate profiles to LDAP [25/28]: importing IPA certificate profiles [26/28]: adding default CA ACL [27/28]: adding 'ipa' CA entry [28/28]: configuring certmonger renewal for lightweight CAs Done configuring certificate server (pki-tomcatd). Configuring directory server (dirsrv) [1/3]: configuring TLS for DS instance [2/3]: adding CA certificate entry [3/3]: restarting directory server Done configuring directory server (dirsrv). Configuring ipa-otpd [1/2]: starting ipa-otpd [2/2]: configuring ipa-otpd to start on boot Done configuring ipa-otpd. Configuring the web interface (httpd) [1/22]: stopping httpd [2/22]: setting mod_nss port to 443 [3/22]: setting mod_nss cipher suite [4/22]: setting mod_nss protocol list to TLSv1.0 - TLSv1.2 [5/22]: setting mod_nss password file [6/22]: enabling mod_nss renegotiate [7/22]: disabling mod_nss OCSP [8/22]: adding URL rewriting rules [9/22]: configuring httpd [10/22]: setting up httpd keytab [11/22]: configuring Gssproxy [12/22]: setting up ssl [13/22]: configure certmonger for renewals [14/22]: importing CA certificates from LDAP [15/22]: publish CA cert [16/22]: clean up any existing httpd ccaches [17/22]: configuring SELinux for httpd [18/22]: create KDC proxy config [19/22]: enable KDC proxy [20/22]: starting httpd [21/22]: configuring httpd to start on boot [22/22]: enabling oddjobd Done configuring the web interface (httpd). Configuring Kerberos KDC (krb5kdc) [1/1]: installing X509 Certificate for PKINIT Done configuring Kerberos KDC (krb5kdc). Applying LDAP updates Upgrading IPA:. Estimated time: 1 minute 30 seconds [1/10]: stopping directory server [2/10]: saving configuration [3/10]: disabling listeners [4/10]: enabling DS global lock [5/10]: disabling Schema Compat [6/10]: starting directory server [7/10]: upgrading server [8/10]: stopping directory server [9/10]: restoring configuration [10/10]: starting directory server Done. Restarting the KDC Configuring DNS (named) [1/12]: generating rndc key file [2/12]: adding DNS container [3/12]: setting up our zone [4/12]: setting up reverse zone [5/12]: setting up our own record [6/12]: setting up records for other masters [7/12]: adding NS record to the zones [8/12]: setting up kerberos principal [9/12]: setting up named.conf [10/12]: setting up server configuration [11/12]: configuring named to start on boot [12/12]: changing resolv.conf to point to ourselves Done configuring DNS (named). Restarting the web server to pick up resolv.conf changes Configuring DNS key synchronization service (ipa-dnskeysyncd) [1/7]: checking status [2/7]: setting up bind-dyndb-ldap working directory [3/7]: setting up kerberos principal [4/7]: setting up SoftHSM [5/7]: adding DNSSEC containers [6/7]: creating replica keys [7/7]: configuring ipa-dnskeysyncd to start on boot Done configuring DNS key synchronization service (ipa-dnskeysyncd). Restarting ipa-dnskeysyncd Restarting named Updating DNS system records Configuring client side components Using existing certificate '/etc/ipa/ca.crt'. Client hostname: node1.example.com Realm: EXAMPLE.COM DNS Domain: example.com IPA Server: node1.example.com BaseDN: dc=example,dc=com Skipping synchronizing time with NTP server. New SSSD config will be created Configured sudoers in /etc/nsswitch.conf Configured /etc/sssd/sssd.conf trying https://node1.example.com/ipa/json [try 1]: Forwarding 'schema' to json server 'https://node1.example.com/ipa/json' trying https://node1.example.com/ipa/session/json [try 1]: Forwarding 'ping' to json server 'https://node1.example.com/ipa/session/json' [try 1]: Forwarding 'ca_is_enabled' to json server 'https://node1.example.com/ipa/session/json' Systemwide CA database updated. Adding SSH public key from /etc/ssh/ssh_host_ecdsa_key.pub Adding SSH public key from /etc/ssh/ssh_host_rsa_key.pub Adding SSH public key from /etc/ssh/ssh_host_ed25519_key.pub [try 1]: Forwarding 'host_mod' to json server 'https://node1.example.com/ipa/session/json' SSSD enabled Configured /etc/openldap/ldap.conf Configured /etc/ssh/ssh_config Configured /etc/ssh/sshd_config Configuring example.com as NIS domain. Client configuration complete. The ipa-client-install command was successful ============================================================================== 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 * 53: bind UDP Ports: * 88, 464: kerberos * 53: bind * 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
So looks like our FreeIPA central Identity Server configuration has completed successfully. As you see the service expects to open some of the required firewall ports which we will open in next steps.
Generate a Kerberos ticket
Now obtain a kerberos ticket using the command “
kinit admin“. This ticket will allow us to use the IPA tools. So getting a kerberos ticket means that we will authenticate as administrator.
[root@node1 ~]# kinit admin Password for admin@EXAMPLE.COM:
After providing the password for admin user nothing changes, but at least we can use some of the IPA utilities.
Managing Users and Groups in FreeIPA
The IPA server is about identity, policy, and authentication. One important part of the IPA server are the users and groups. That’s one of the main reasons why companies start using IPA because they don’t want to manage their users on individual Linux servers. They want to create an LDAP server, which is the IPA server, to centrally manage user and group accounts.
Open the browser on node1 and navigate to
node1.example.com to open the FreeIPA portal.
Next this is providing the login interface where we can login as user admin with a password that you have provided when you installed the IPA server. This is the main management interface of the IPA server. To start it, I want to create some users. We have this category users in order to add a user. Click on “Add” as shown below.
Provide the user details as shown in the below snippet and click on “Add”
Next verify if the user ‘deepak’ is properly created.
You can also create a user using the command line ipa tool. Execute the below command and follow the prompts to create the user.
[root@node1 ~]# ipa user-add First name: rahul Last name: raj User login [rraj]: rahul ------------------ Added user "rahul" ------------------ User login: rahul First name: rahul Last name: raj Full name: rahul raj Display name: rahul raj Initials: rr Home directory: /home/rahul GECOS: rahul raj Login shell: /bin/sh Principal name: rahul@EXAMPLE.COM Principal alias: rahul@EXAMPLE.COM Email address: firstname.lastname@example.org UID: 700200003 GID: 700200003 Password: False Member of groups: ipausers Kerberos keys available: False
Here we have created two users,
deepak is created using the FreeIPA GUI and
rahul is created using ipa cli tool.
Opening the Firewall for IPA traffic
In firewall D, we have this notion of services. If we use firewall-cmd–get-services, then we get a list of all services that are available. There are some services that involve IPA, and that is freeipa-ldap and freeipa-ldaps. These services have a backing XML file, and you will find it in /usr/lib/firewalld/services.
[root@node1 services]# cd /usr/lib/firewalld/services [root@node1 services]# ls freeipa-* freeipa-ldaps.xml freeipa-ldap.xml freeipa-replication.xml freeipa-trust.xml
So if you look at the contents of
freeipa-ldap.xml, now we can see that it is opening this list of ports. If you compare that to the list of ports we were asked to open while installing the IPA server, then you can see that most of the ports are already in there.
Below are the list of ports which must be opened for FreeIPA server
TCP Ports: * 80, 443: HTTP/HTTPS * 389, 636: LDAP/LDAPS * 88, 464: kerberos * 53: bind UDP Ports: * 88, 464: kerberos * 53: bind * 123: ntp
Let us add all the required service in the firewalld to open the ports needed by FreeIPA
[root@node1 services]# firewall-cmd --permanent --add-service freeipa-ldap success [root@node1 services]# firewall-cmd --permanent --add-service freeipa-ldaps success [root@node1 services]# firewall-cmd --permanent --add-service dns success
Now let us make our changes persistent
[root@node1 services]# firewall-cmd --reload success
Verify the firewall rules which we have just added.
[root@node1 services]# firewall-cmd --list-all public (active) target: default icmp-block-inversion: no interfaces: eth0 eth1 sources: services: ssh dhcpv6-client freeipa-ldap freeipa-ldaps dns ports: protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules:
Joining client to IPA domain
Next we are going to join a server (ipa client) to the IPA domain. Before joining the server to the IPA domain, there are certain pre-requisites to be taken care on the ipa client.
Update hosts file
/etc/hosts has the FQDN details of your IPA server and localhost.
[root@node2 ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 10.0.2.31 node2.example.com node2 10.0.2.30 node1.example.com node1 10.0.2.32 node3.example.com node3
Update DNS on IPA client
Next update the DNS record on your ipa client to use IPA server as your DNS. Because the ipa client must be able to reach the IPA server for authentication and communication. Hence we have added DNS entry in my primary interface configuration file on the ipa client as shown below
[root@node2 ~]# cat /etc/sysconfig/network-scripts/ifcfg-Wired_connection_1 HWADDR=08:00:27:DF:87:41 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=none IPADDR=10.0.2.31 PREFIX=8 GATEWAY=10.0.2.2 DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=no NAME="Wired connection 1" UUID=415ba198-453b-38f2-99cd-3281f4aec264 ONBOOT=yes AUTOCONNECT_PRIORITY=-999 DNS1=10.0.2.30
Next restart your network services
[root@node2 ~]# systemctl restart network [root@node2 ~]# systemctl restart NetworkManager
Next validate the
resolv.conf, it should point to your IPA server IP as a nameserver.
[root@node2 ~]# cat /etc/resolv.conf # Generated by NetworkManager nameserver 10.0.2.30
Next check and make sure you are still able to connect to the internet.
[root@node2 ~]# ping google.com PING google.com (22.214.171.124) 56(84) bytes of data. 64 bytes from 126.96.36.199 (188.8.131.52): icmp_seq=1 ttl=53 time=55.4 ms ^C --- google.com ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 55.414/55.414/55.414/0.000 ms
So all looks good and we can now configure our client to connect to the IPA server.
Configure IPA client
To set up your ipa client and for the ipa client to be able to join your IPA server domain, install
ipa-client rpm as shown below.
[root@node2 ~]# yum install ipa-client -y
Next run the below command to setup your
ipa client. This will prompt you with a series of questions, follow the snippet below and accordingly set up your client.
[root@node2 ~]# ipa-client-install WARNING: ntpd time&date synchronization service will not be configured as conflicting service (chronyd) is enabled Use --force-ntpd option to disable it and force configuration of ntpd Discovery was successful! Client hostname: node2.example.com Realm: EXAMPLE.COM DNS Domain: example.com IPA Server: node1.example.com BaseDN: dc=example,dc=com Continue to configure the system with these values? [no]: yes Skipping synchronizing time with NTP server. User authorized to enroll computers: admin Password for admin@EXAMPLE.COM: Successfully retrieved CA cert Subject: CN=Certificate Authority,O=EXAMPLE.COM Issuer: CN=Certificate Authority,O=EXAMPLE.COM Valid From: 2019-04-09 12:26:00 Valid Until: 2039-04-09 12:26:00 Enrolled in IPA realm EXAMPLE.COM Created /etc/ipa/default.conf New SSSD config will be created Configured sudoers in /etc/nsswitch.conf Configured /etc/sssd/sssd.conf Configured /etc/krb5.conf for IPA realm EXAMPLE.COM trying https://node1.example.com/ipa/json [try 1]: Forwarding 'schema' to json server 'https://node1.example.com/ipa/json' trying https://node1.example.com/ipa/session/json [try 1]: Forwarding 'ping' to json server 'https://node1.example.com/ipa/session/json' [try 1]: Forwarding 'ca_is_enabled' to json server 'https://node1.example.com/ipa/session/json' Systemwide CA database updated. Hostname (node2.example.com) does not have A/AAAA record. Missing reverse record(s) for address(es): 10.0.2.31. Adding SSH public key from /etc/ssh/ssh_host_ecdsa_key.pub Adding SSH public key from /etc/ssh/ssh_host_rsa_key.pub Adding SSH public key from /etc/ssh/ssh_host_ed25519_key.pub [try 1]: Forwarding 'host_mod' to json server 'https://node1.example.com/ipa/session/json' SSSD enabled Configured /etc/openldap/ldap.conf Configured /etc/ssh/ssh_config Configured /etc/ssh/sshd_config Configuring example.com as NIS domain. Client configuration complete. The ipa-client-install command was successful
If everything is correct and proper then your client will successfully join the IPA server domain. next generate a kerberos ticket for your ipa client using the below command
[root@node2 ~]# kinit admin Password for admin@EXAMPLE.COM:
If there are no error messages on the screen it means you have successfully generated a kerberos token on your ipa client which you can validate using the below command.
[root@node2 ~]# klist Ticket cache: KEYRING:persistent:0:0 Default principal: admin@EXAMPLE.COM Valid starting Expires Service principal 04/09/2019 18:35:23 04/10/2019 18:35:20 krbtgt/EXAMPLE.COM@EXAMPLE.COM
With this we have successfully setup our IPA client. You can validate the ipa client by logging on the IPA server GUI on node1.example.com
Lastly I hope the steps from the article to configure Central Identity Server (FreeIPA) and ipa client on Linux was helpful. So, let me know your suggestions and feedback using the comment section.