Install and Configure FreeIPA Client on Ubuntu 24.04<\/a><\/p>\n\n\n\nConfiguring Host-Based Access Control<\/h3>\n\n\n\n Now that you have FreeIPA server up and running, with user accounts already added, it is now time to restrict users to specific systems based on their hostnames.<\/p>\n\n\n\n
You can configure FreeIPA host-based access control via web user interface or via the command line.<\/p>\n\n\n\n
Login to FreeIPA web dashboard as IPA admin and navigate to Policy > Host Based Access Control<\/strong>. Click drop-down button and select HBAC Rules<\/strong> (selected by default).<\/p>\n\n\n\n <\/figure>\n\n\n\nYou will see default HBAC rules. Click Add<\/strong> on the right side to add the rules. Add HBAC rules<\/strong> wizard pops up. <\/p>\n\n\n\nEnter the name of the rule and click “Add and Edit<\/strong>“. Note that I am interested in allowing users to access ONLY their work stations and not any other user’s workstation, for example.<\/p>\n\n\n\nIt is also possible ti create access based on groups and their roles!<\/p>\n\n\n\n
Thus:<\/p>\n\n\n\n
\nunder General<\/strong> settings, you can optionally set a description of the access control.<\/li>\n\n\n\nspecify Who<\/strong> the rules applies to. Click Add<\/strong> to select and add the user.<\/li>\n\n\n\nunder Accessing<\/strong>, select and add hosts the user is allowed to access<\/li>\n\n\n\non Via Service, select which service to allow the user on the host. FreeIPA server ships with some common services and service groups configured for HBAC rules by default. Check them under Policy > Host-Based Access Control>HBAC Services<\/strong>.<\/strong> Here, am only interested in login<\/strong> service.<\/li>\n<\/ul>\n\n\n\n <\/figure>\n\n\n\nClick Save<\/strong> (just above the General settings) to save the rules.<\/p>\n\n\n\nTesting HBAC Rules on Web UI<\/h4>\n\n\n\n You can now test the rules against the host to confirm if they work. Ensure that you have enrolled the host (installed the FreeIPA client and connected the client host to the server already).<\/p>\n\n\n\n
Under Policy > Host-Based Access Control<\/strong><\/strong>, click HBAC Test<\/strong> and:<\/p>\n\n\n\n\nWho<\/strong>: Select the user whom you want to test<\/li>\n\n\n\nAccessing<\/strong>: Select the system to test access against<\/li>\n\n\n\nVia Service<\/strong>: Select specific service to test. We are doing login here.<\/li>\n\n\n\nRules<\/strong>: Select the individual user rule we created before.<\/li>\n\n\n\nRun test<\/strong>: Click Run test<\/strong> to confirm the user login against the host.<\/li>\n<\/ol>\n\n\n\n <\/figure>\n\n\n\nThe results of a test can either be:<\/p>\n\n\n\n
\nACCESS GRANTED<\/strong>, the user is able to access the host successfully.<\/li>\n\n\n\nACCESS DENIED<\/strong>, the user is not granted access in the test.<\/li>\n<\/ul>\n\n\n\nYou can do more access controls based on your use cases!<\/p>\n\n\n\n
Disable Allow_All Rule<\/h4>\n\n\n\n You can now disable allow_all rule.<\/p>\n\n\n\n
Select the rule from HBAC Rules and disable it.<\/p>\n\n\n\n
Similarly, you can also use IPA command line tools to configure host based access control.<\/p>\n\n\n\n
There is quite a number of IPA command line arguments that you can use to manage HBAC on FreeIPA.<\/p>\n\n\n\n
hbacrule-add hbacrule-add-user hbacrule-enable hbacrule-remove-host hbacrule-show\nhbacrule-add-host hbacrule-del hbacrule-find hbacrule-remove-service \nhbacrule-add-service hbacrule-disable hbacrule-mod hbacrule-remove-user\n<\/code><\/pre>\n\n\n\nYou can list all the rules using;<\/p>\n\n\n\n
ipa hbacrule-find --all<\/code><\/pre>\n\n\n\nTo add HBAC rule, use the command, ipa hbacrule-add<\/strong>.<\/p>\n\n\n\nipa hbacrule-add<\/code><\/pre>\n\n\n\nYou will be prompted for rule name ;<\/p>\n\n\n\n
Rule name: bparker\n-------------------------\nAdded HBAC rule \"bparker\"\n-------------------------\n Rule name: bparker\n Enabled: True\n<\/code><\/pre>\n\n\n\nNext, apply the rule to the user;<\/p>\n\n\n\n
ipa hbacrule-add-user --users=bparker<\/strong><\/code><\/pre>\n\n\n\nWhere bparker<\/strong> is my user. <\/p>\n\n\n\nRule name: bparker\n Rule name: bparker\n Enabled: True\n Users: bparker\n-------------------------\nNumber of members added 1\n-------------------------\n<\/code><\/pre>\n\n\n\nNext define the hosts as well as the service to grant user access to:<\/p>\n\n\n\n
ipa hbacrule-add-host bparker --hosts=node02.kifarunix.com<\/code><\/pre>\n\n\n\n Rule name: bparker\n Enabled: True\n Users: bparker\n Hosts: node02.kifarunix.com\n-------------------------\nNumber of members added 1\n-------------------------\n<\/code><\/pre>\n\n\n\nipa hbacrule-add-service bparker --hbacsvcs=login<\/code><\/pre>\n\n\n\n Rule name: bparker\n Enabled: True\n Users: bparker\n Hosts: node02.kifarunix.com\n HBAC Services: login\n-------------------------\nNumber of members added 1\n-------------------------\n<\/code><\/pre>\n\n\n\nAnd that is it.<\/p>\n\n\n\n
Confirm availability of the rule;<\/p>\n\n\n\n
ipa hbacrule-find<\/code><\/pre>\n\n\n\n--------------------\n4 HBAC rules matched\n--------------------\n Rule name: allow_all\n User category: all\n Host category: all\n Service category: all\n Description: Allow all users to access any host from any host\n Enabled: True\n\n Rule name: allow_systemd-user\n User category: all\n Host category: all\n Description: Allow pam_systemd to run user@.service to create a system user session\n Enabled: True\n\n Rule name: bcooper\n Description: Allow Cooper to Login to their Machine Only\n Enabled: True\n\n Rule name: bparker\n Enabled: True\n----------------------------\nNumber of entries returned 4\n----------------------------<\/strong>\n<\/code><\/pre>\n\n\n\nCheck details;<\/p>\n\n\n\n
ipa hbacrule-show bparker<\/code><\/pre>\n\n\n\n Rule name: bparker\n Enabled: True\n Users: bparker\n Hosts: node02.kifarunix.com\n HBAC Services: login\n<\/code><\/pre>\n\n\n\nTest the HBAC Rule on Command Line<\/h4>\n\n\n\n You can now use the command, ipa hbactest<\/strong>, to test the access granted to the user on the respective host.<\/p>\n\n\n\nipa hbactest --user=<user> --host=<host> --service=<service> --rules=<rule-name><\/code><\/pre>\n\n\n\nE.g<\/p>\n\n\n\n
ipa hbactest --user=bparker --host=node02.kifarunix.com --service=login --rules=bparker<\/code><\/pre>\n\n\n\nIf success, you get Access granted: True<\/strong> otherwise False.<\/strong><\/p>\n\n\n\n--------------------\nAccess granted: True\n--------------------\n Matched rules: bparker\n<\/code><\/pre>\n\n\n\nDisable Allow_all Rule on CLI<\/h4>\n\n\n\n You can disable allow all rule on CLI;<\/p>\n\n\n\n
ipa hbacrule-disable allow_all<\/code><\/pre>\n\n\n\nVerify Host Based Authentication<\/h3>\n\n\n\n You can now try to login to the respective systems using respective user accounts.<\/p>\n\n\n\n
For example, let’s SSH into Node02 as Bparker;<\/p>\n\n\n\n
ssh bparker@192.168.122.81<\/code><\/pre>\n\n\n\nif success, you are prompted to first reset the password (if first login);<\/p>\n\n\n\n
ssh bparker@192.168.122.81\n(bparker@192.168.122.81) Password: \nPassword expired. Change your password now.\n(bparker@192.168.122.81) Current Password: \n(bparker@192.168.122.81) New password: \n(bparker@192.168.122.81) Retype new password: \nCreating directory '\/home\/bparker'.\nWelcome to Ubuntu 24.04 LTS (GNU\/Linux 6.8.0-31-generic x86_64)\n\n * Documentation: https:\/\/help.ubuntu.com\n * Management: https:\/\/landscape.canonical.com\n * Support: https:\/\/ubuntu.com\/pro\n\n System information as of Sat May 4 01:52:35 PM UTC 2024\n\n System load: 0.04 Processes: 154\n Usage of \/: 45.4% of 11.21GB Users logged in: 1\n Memory usage: 8% IPv4 address for enp1s0: 192.168.122.81\n Swap usage: 0%\n\n * Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s\n just raised the bar for easy, resilient and secure K8s cluster deployment.\n\n https:\/\/ubuntu.com\/engage\/secure-kubernetes-at-the-edge\n\nExpanded Security Maintenance for Applications is not enabled.\n\n0 updates can be applied immediately.\n\nEnable ESM Apps to receive additional future security updates.\nSee https:\/\/ubuntu.com\/esm or run: sudo pro status\n\n\n\nThe programs included with the Ubuntu system are free software;\nthe exact distribution terms for each program are described in the\nindividual files in \/usr\/share\/doc\/*\/copyright.\n\nUbuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by\napplicable law.\n\n$ hostname \t\nnode02\n$\n<\/code><\/pre>\n\n\n\nIf you try to login as another user or to a system whose access is not granted, then, it will fail. Such example logs for SSH.<\/p>\n\n\n\n
2024-05-04T16:57:32.396021+03:00 noble sshd[12352]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.122.1 user=bparker\n2024-05-04T16:57:32.456847+03:00 noble sshd[12352]: pam_sss(sshd:auth): authentication success; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.122.1 user=bparker\n2024-05-04T16:57:32.479841+03:00 noble sshd[12352]: pam_sss(sshd:account): Access denied for user bparker: 6 (Permission denied)\n2024-05-04T16:57:32.480226+03:00 noble sshd[12349]: error: PAM: User account has expired for bparker from 192.168.122.1\n2024-05-04T16:57:32.491282+03:00 noble sshd[12349]: fatal: monitor_read: unpermitted request 104\n<\/code><\/pre>\n\n\n\nAnd that is it. You can fine grain your rules to suit your needs.<\/p>\n\n\n\n
That concludes our guide on how to setup host based access control on FreeIPA.<\/p>\n\n\n\n
If you are using OpenLDAP, check;<\/p>\n\n\n\n
Configure OpenLDAP Host Based Authentication<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"Follow through this guide to learn how to configure Host-based access control on FreeIPA server. If you are using FreeIPA to manage authentication, you might<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,285,1152],"tags":[247,7478,7480,7479],"class_list":["post-22418","post","type-post","status-publish","format-standard","hentry","category-howtos","category-directory-server","category-freeipa","tag-freeipa","tag-freeipa-hbac-rules","tag-hbac","tag-host-based-authentication","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/22418"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=22418"}],"version-history":[{"count":6,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/22418\/revisions"}],"predecessor-version":[{"id":22434,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/22418\/revisions\/22434"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=22418"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=22418"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=22418"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}