#author("2025-10-04T15:10:47+00:00","default:sysosa","sysosa") #author("2025-11-26T19:19:58+00:00;2025-10-04T15:10:47+00:00","default:sysosa","sysosa") FreeIPAにLinuxマシンを参加させます. ***下準備 [#jc6095a0] 時計合わせは大事. #code(nonumber){{ [root@freeipa-client ~]# cat /etc/redhat-release Rocky Linux release 9.6 (Blue Onyx) [root@freeipa-client ~]# echo `hostname -i` `hostname -f` `hostname -s` >> /etc/hosts [root@freeipa-client ~]# echo "server c.sybyl.local" > /etc/chrony.conf [root@freeipa-client ~]# echo "server c.sybyl.local iburst" > /etc/chrony.conf [root@freeipa-client ~]# systemctl enable chronyd --now }} ***パッケージインストール [#a806a0d4] パッケージをインストールします. 使用するコマンドは「dnf install ipa-client」です #code(nonumber){{ [root@freeipa-client ~]# dnf install ipa-client -y }} ***参加作業 [#b528e667] FreeIPAサーバに参加するには「ipa-client-install」を使用します. OS側のntp(chrony)が使えるので「--no-ntp」を有効にします #code(nonumber){{ [root@freeipa-client ~]# ipa-client-install --no-ntp This program will set up IPA client. Version 4.12.2 Discovery was successful! Client hostname: freeipa-client.sybyl.local Realm: SYBYL.LOCAL DNS Domain: sybyl.local IPA Server: freeipa.sybyl.local BaseDN: dc=sybyl,dc=local Continue to configure the system with these values? [no]: yes <-- この構成で続けるので「yes」 Skipping chrony configuration User authorized to enroll computers: admin <--- freeipaとつないでチケットをもらうのですが、そのアカウントを指定 Password for admin@SYBYL.LOCAL: <--- 「admin@SYBYL.LOCAL」のチケットをもらうためにパスワードを入力 Successfully retrieved CA cert Subject: CN=Certificate Authority,O=SYBYL.LOCAL Issuer: CN=Certificate Authority,O=SYBYL.LOCAL Valid From: 2025-09-27 19:27:06+00:00 Valid Until: 2045-09-27 19:27:06+00:00 Enrolled in IPA realm SYBYL.LOCAL Created /etc/ipa/default.conf Configured /etc/sssd/sssd.conf 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_ed25519_key.pub Adding SSH public key from /etc/ssh/ssh_host_rsa_key.pub Could not update DNS SSHFP records. SSSD enabled Configured /etc/openldap/ldap.conf Configured /etc/ssh/ssh_config Configured /etc/ssh/sshd_config.d/04-ipa.conf Configuring sybyl.local as NIS domain. Configured /etc/krb5.conf for IPA realm SYBYL.LOCAL Client configuration complete. The ipa-client-install command was successful [root@freeipa-client ~]# }} ***確認 [#x3c72db2] ipa-client-installの完成後には sssd が動いていて下記のようになっている #code(nonumber){{ [root@freeipa-client ~]# authselect current Profile ID: sssd Enabled features: - with-sudo [root@freeipa-client ~]# }} っでこの段階で既にidとかは拾える &size(10){既に作ってればね}; #code(nonumber){{ [root@freeipa-client ~]# id arcueid uid=3001(arcueid) gid=2003(em) groups=2003(em) [root@freeipa-client ~]# getent passwd arcueid arcueid:*:3001:2003:Arcueid Brunestud:/home/arcueid:/bin/bash [root@freeipa-client ~]# }} ***FreeIPAサーバにてnfsサービスプリンシパルを作る [#jf925ae3] freeipa内でkrb5を使ったnfs mountをするにはクライアントに nfsサービスプリンシパル が必要. なのでnfs-client向けのnfsサービスプリンシパルをfreeipaサーバにて作ります まず管理者チケットを貰います #code(nonumber){{ [root@freeipa ~]# kinit admin Password for admin@SYBYL.LOCAL: [root@freeipa ~]# }} freeipa-clientへのサービス記述子がnfsのサービスプリンシパルを作る #code(nonumber){{ [root@freeipa ~]# ipa service-add nfs/freeipa-client.sybyl.local ---------------------------------------------------------- Added service "nfs/freeipa-client.sybyl.local@SYBYL.LOCAL" ---------------------------------------------------------- Principal name: nfs/freeipa-client.sybyl.local@SYBYL.LOCAL Principal alias: nfs/freeipa-client.sybyl.local@SYBYL.LOCAL Managed by: freeipa-client.sybyl.local [root@freeipa ~]# (確認) [root@freeipa ~]# ipa service-find freeipa-client.sybyl.local ----------------- 1 service matched ----------------- Principal name: nfs/freeipa-client.sybyl.local@SYBYL.LOCAL Principal alias: nfs/freeipa-client.sybyl.local@SYBYL.LOCAL Keytab: False ---------------------------- Number of entries returned 1 ---------------------------- [root@freeipa ~]# }} ***krb5.keytabの更新 [#fb9d1800] 既にFreeIPAに参加しているので 既に /etc/krb5.keytab は持っている. これを更新して作ったnfsサービスプリンシパルを追記させます #code(nonumber){{ [root@freeipa-client ~]# klist -ke /etc/krb5.keytab Keytab name: FILE:/etc/krb5.keytab KVNO Principal ---- -------------------------------------------------------------------------- 1 host/freeipa-client.sybyl.local@SYBYL.LOCAL (aes256-cts-hmac-sha384-192) 1 host/freeipa-client.sybyl.local@SYBYL.LOCAL (aes128-cts-hmac-sha256-128) 1 host/freeipa-client.sybyl.local@SYBYL.LOCAL (aes256-cts-hmac-sha1-96) 1 host/freeipa-client.sybyl.local@SYBYL.LOCAL (aes128-cts-hmac-sha1-96) [root@freeipa-client ~]# kinit admin [root@freeipa-client ~]# ipa-getkeytab -s freeipa.sybyl.local -p nfs/freeipa-client.sybyl.local -k /etc/krb5.keytab Keytab successfully retrieved and stored in: /etc/krb5.keytab [root@freeipa-client ~]# klist -ke /etc/krb5.keytab Keytab name: FILE:/etc/krb5.keytab KVNO Principal ---- -------------------------------------------------------------------------- 1 host/freeipa-client.sybyl.local@SYBYL.LOCAL (aes256-cts-hmac-sha384-192) 1 host/freeipa-client.sybyl.local@SYBYL.LOCAL (aes128-cts-hmac-sha256-128) 1 host/freeipa-client.sybyl.local@SYBYL.LOCAL (aes256-cts-hmac-sha1-96) 1 host/freeipa-client.sybyl.local@SYBYL.LOCAL (aes128-cts-hmac-sha1-96) 1 nfs/freeipa-client.sybyl.local@SYBYL.LOCAL (aes256-cts-hmac-sha384-192) 1 nfs/freeipa-client.sybyl.local@SYBYL.LOCAL (aes128-cts-hmac-sha256-128) 1 nfs/freeipa-client.sybyl.local@SYBYL.LOCAL (aes256-cts-hmac-sha1-96) 1 nfs/freeipa-client.sybyl.local@SYBYL.LOCAL (aes128-cts-hmac-sha1-96) [root@freeipa-client ~]# }} 次に「ipa-client-automount」を実行する #code(nonumber){{ [root@freeipa-client ~]# ipa-client-automount Searching for IPA server... IPA server: DNS discovery Location: default Continue to configure the system with these values? [no]: yes <--- IPAサーバの値とlocationの値が正しいなら[yes] Configured /etc/idmapd.conf Restarting sssd, waiting for it to become available. Started autofs [root@freeipa-client ~]# (確認) [root@freeipa-client ~]# ls -l /apps /home [root@freeipa-client ~]# df -Th /home /apps Filesystem Type Size Used Avail Use% Mounted on freeipa-nfs:/home nfs4 32G 261M 32G 1% /home freeipa-nfs:/apps nfs4 32G 261M 32G 1% /apps [root@freeipa-client ~]# [root@freeipa-client ~]# mount |grep -e apps -e home auto.direct on /home type autofs (rw,relatime,fd=6,pgrp=35210,timeout=300,minproto=5,maxproto=5,direct,pipe_ino=73048) freeipa-nfs:/home on /home type nfs4 (rw,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=krb5,clientaddr=192.168.0.147,local_lock=none,addr=192.168.0.149) auto.direct on /apps type autofs (rw,relatime,fd=6,pgrp=35210,timeout=300,minproto=5,maxproto=5,direct,pipe_ino=73048) freeipa-nfs:/apps on /apps type nfs4 (rw,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=krb5,clientaddr=192.168.0.147,local_lock=none,addr=192.168.0.149) [root@freeipa-client ~]# [root@freeipa-client ~]# setsebool -P use_nfs_home_dirs 1 <-- SELinux対応 }} 「sec=krb5」が入っているのでkerberosでnfsが行っているみたい. 「sec=krb5i」で繋ぎたければ「ipa automountkey-mod default auto.direct」で修正します &size(10){sec欄がkrb5iならチェックサム付き、krb5pならnfsトラフィックの暗号化が行えます}; ***めも [#o93948c2] 設定を変更するには一度「ipa-client-install --uninstall」を実行してから行う事. すぐさま再起動を要求されます. ホームディレクトリを設けるなら「ipa-client-install」のオプションとして更に「--mkhomedir」を付けて設定を行います ですがホームディレクトリ先をnfsで受けるなら、nfsサーバを作ってそこで「mkhomedir_helper」コマンドでホームディレクトリを作ったほうがいい. 「ipa-client-install」の「--mkhomedir」はローカルにホームディレクトリを作る際のお話かなと. #code(nonumber){{ [root@freeipa-client ~]# ls -l /home total 0 [root@freeipa-client ~]# su - arcueid Creating home directory for arcueid. [arcueid@freeipa-client ~]$ pwd /home/arcueid [arcueid@freeipa-client ~]$ }} クライアントを設定するとおおもとのFreeIPAサーバにも設定されます. #code(nonumber){{ [root@freeipa ~]# ipa host-show freeipa-client Host name: freeipa-client.sybyl.local Platform: x86_64 Operating system: 5.14.0-570.42.2.el9_6.x86_64 Principal name: host/freeipa-client.sybyl.local@SYBYL.LOCAL Principal alias: host/freeipa-client.sybyl.local@SYBYL.LOCAL SSH public key fingerprint: (略 Password: False Keytab: True Managed by: freeipa-client.sybyl.local [root@freeipa ~]# }} ***ログイン [#s890d63e] freeipaで作成したアカウントでログインを試みると初期パスワードが問われます その後すぐさま、パスワードの変更が求められ、パスワードが変更されるとログインに成功します。 もちろん次回以降は変更したパスワードでログインになるだけです. #code(nonumber){{ [llya@c ~]$ ssh -l arcueid freeipa-client Password: <--- 初期パスワードが問われます Password expired. Change your password now. Current Password: New password: Retype new password: Last login: Sun Sep 28 08:47:12 2025 [illya@freeipa-client ~]$ }} ***メモ(ログイン、ログアウトが遅くなる) [#h981b123] freeipaで作られたユーザのログイン、ログアウトにタイムラグが発生する時がある。 これは &color(magenta){sec=krb5}; を使った時のお話です。従来の &color(orangered){sec=sys}; の時はタイムラグは発生しないですね。 いろいろ調査して試してみたけど、早くなったり遅くなったり再現性が皆無. &color(magenta){sec=krb5};による利点は、mount先へのアクセスが認証によって担保される点. 従来の&color(orangered){sec=sys};では勝手に作ったnfsクライアントでuidを真似されると他人の中身が見えてしまいます。 以外にnfsはセキュアではない. ですが、ログインが遅いとかログアウトが遅いのは問題で、現状は従来型の&color(orangered){sec=sys};に頼るしかないみたい. #code(nonumber){{ [root@freeipa ~]# ipa automountkey-mod default auto.direct --key="/home" --info="-rw freeipa-nfs:/home" --newinfo="-rw,sec=sys freeipa-nfs:/home" }} と&color(orangered){sec=sys};に変更して freeipa-nfs にて sys でのmountを許可するように変更します #code(nonumber){{ [root@freeipa-nfs ~]# vi /etc/exports /nfs 192.168.0.0/255.255.255.0(rw,sync,fsid=0) /nfs/home 192.168.0.0/255.255.255.0(rw,sync,nohide) /nfs/apps 192.168.0.0/255.255.255.0(rw,sync,nohide) [root@freeipa-nfs ~]# systemctl restart nfs-server }} として &color(orangered){sec=sys}; によるautofsを利用します。 &color(orangered){sec=sys};でセキュアを保つには...802.1X認証HUBを設けてもアンマネージドHUBを入れたら意味ないし難しいですねぇ... samba-adならkrb5通信にこのようなログイン・ログアウトが遅いとかの問題は見てないですねぇ.. 今後も管理対象区分かな.