ディレクトリサーバのFreeIPA、ログインノード、計算ノード、ストレージノードな構成を考える.
ログインノード、計算ノードにnfsでストレージを供給するストレージサーバ、構成はxfs, zfs, btrfs, cephfs, BeeGFSなどいろいろあるが、FreeIPAでのnfsサーバを作ってみる.

2022y04m29d_014741674.png

やっていることはsamba/NFSと同じくサービス記述子nfsをもつサービスプリンシパルを持たせてkerberosによるnfsかな.
もちろんこの操作をしなくてもsysな従来からのuidベースのnfsとしてFreeIPA関係なく構築もできるけどね

参照先 https://blog.delouw.ch/2015/03/14/using-ipa-to-provide-automount-maps-for-nfsv4-home-directories/様 thanks

nfsサーバをFreeIPAドメイン参加させる

nfsサーバには RockyLinux 9.5 を使ってます

[root@freeipa-nfs ~]# cat /etc/redhat-release
Rocky Linux release 9.5 (Blue Onyx)
 
[root@freeipa-nfs ~]# getenforce
Enforcing
[root@freeipa-nfs ~]#

FreeIPAのclientパッケージを入れます

[root@freeipa-nfs ~]# dnf install ipa-client -y

chronyの設定を施します

[root@freeipa-nfs ~]# echo "server c.sybyl.local" > /etc/chrony.conf
[root@freeipa-nfs ~]# systemctl restart chronyd

っで「ipa-client-install」コマンドでfreeipaの傘下に入ります.

[root@freeipa-nfs ~]# ipa-client-install --no-ntp    <-- chronyの設定があるのでfreeipaでのntp設定は不要
This program will set up IPA client.
Version 4.12.2
 
Discovery was successful!
Client hostname: freeipa-nfs.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サーバの登録管理者admin
Password for admin@SYBYL.LOCAL:                        <--- 登録管理者adminのパスワードを入力
 
Successfully retrieved CA cert
    Subject:     CN=Certificate Authority,O=SYBYL.LOCAL
    Issuer:      CN=Certificate Authority,O=SYBYL.LOCAL
    Valid From:  2025-05-08 16:29:19+00:00
    Valid Until: 2045-05-08 16:29:19+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-nfs ~]#

これでkrb5.keytabが貰える

[root@freeipa-nfs ~]# klist -ke
Keytab name: FILE:/etc/krb5.keytab
KVNO Principal
---- --------------------------------------------------------------------------
   1 host/freeipa-nfs.sybyl.local@SYBYL.LOCAL (aes256-cts-hmac-sha384-192)
   1 host/freeipa-nfs.sybyl.local@SYBYL.LOCAL (aes128-cts-hmac-sha256-128)
   1 host/freeipa-nfs.sybyl.local@SYBYL.LOCAL (aes256-cts-hmac-sha1-96)
   1 host/freeipa-nfs.sybyl.local@SYBYL.LOCAL (aes128-cts-hmac-sha1-96)
[root@freeipa-nfs ~]#

だが、、nfsサービスプリンシパルがないとnfsサーバにはなれないので、その取得を次に行う. 正確には krb5 で繋ぐnfsサーバでしょうか. 普通のnfsはfreeipaに依存しなくても作れます

freeipaサーバで nfsサービスプリンシパル を作る

freeipaサーバにて作業します
まずはkrbチケットを貰って

[root@freeipa ~]# kinit admin
Password for admin@SYBYL.LOCAL:     <--- 登録管理者adminのパスワードを入力
[root@freeipa ~]#

nfsサービスプリンシパルを作ります

[root@freeipa ~]# ipa service-add nfs/freeipa-nfs.sybyl.local
-------------------------------------------------------
Added service "nfs/freeipa-nfs.sybyl.local@SYBYL.LOCAL"
-------------------------------------------------------
  Principal name: nfs/freeipa-nfs.sybyl.local@SYBYL.LOCAL
  Principal alias: nfs/freeipa-nfs.sybyl.local@SYBYL.LOCAL
  Managed by: freeipa-nfs.sybyl.local
[root@freeipa ~]#

これで freeipa-nfs は nfsサービスプリンシパルを持つことになります

nfsサービスプリンシパルを受け取る

そしてFreeIPAサーバからnfsサービスプリンシパルを受け取ります

[root@freeipa-nfs ~]# kinit admin
Password for admin@SYBYL.LOCAL:     <--- 登録管理者adminのパスワードを入力
 
[root@freeipa-nfs ~]# ipa-getkeytab -p nfs/freeipa-nfs.sybyl.local -k /etc/krb5.keytab
Keytab successfully retrieved and stored in: /etc/krb5.keytab
[root@freeipa-nfs ~]#
 
(確認)
[root@freeipa-nfs ~]# klist -ke /etc/krb5.keytab
Keytab name: FILE:/etc/krb5.keytab
KVNO Principal
---- --------------------------------------------------------------------------
   1 host/freeipa-nfs.sybyl.local@SYBYL.LOCAL (aes256-cts-hmac-sha384-192)
   1 host/freeipa-nfs.sybyl.local@SYBYL.LOCAL (aes128-cts-hmac-sha256-128)
   1 host/freeipa-nfs.sybyl.local@SYBYL.LOCAL (aes256-cts-hmac-sha1-96)
   1 host/freeipa-nfs.sybyl.local@SYBYL.LOCAL (aes128-cts-hmac-sha1-96)
   1 nfs/freeipa-nfs.sybyl.local@SYBYL.LOCAL (aes256-cts-hmac-sha384-192)    <-- 以下追加された nfsサービスプリンシパル
   1 nfs/freeipa-nfs.sybyl.local@SYBYL.LOCAL (aes128-cts-hmac-sha256-128)
   1 nfs/freeipa-nfs.sybyl.local@SYBYL.LOCAL (aes256-cts-hmac-sha1-96)
   1 nfs/freeipa-nfs.sybyl.local@SYBYL.LOCAL (aes128-cts-hmac-sha1-96)
 
[root@freeipa-nfs ~]#

nfsサービスを開始

次にnfsとして供出する場所を準備します. ここでは/etc/sdbを/nfsとして/nfs/{home,apps}をexortします.

[root@freeipa-nfs ~]# parted /dev/sdb
(parted) mklabel gpt
(parted) mkpart primary 0% 100%
(parted) quit
[root@freeipa-nfs ~]# mkfs.xfs -L nfs /dev/sdb1
[root@freeipa-nfs ~]# echo "LABEL=nfs /nfs xfs defaults 0 0" >> /etc/fstab
[root@freeipa-nfs ~]# systemctl daemon-reload
[root@freeipa-nfs ~]# mkdir /nfs && mount -a
[root@freeipa-nfs ~]# df -lTh /nfs
Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/sdb1      xfs    50G  389M   50G   1% /nfs
 
[root@freeipa-nfs ~]# mkdir /nfs/{home,apps}
[root@freeipa-nfs ~]# echo "/nfs/home /home none bind 0 0" >> /etc/fstab
[root@freeipa-nfs ~]# systemctl daemon-reload
[root@freeipa-nfs ~]# mount -a
 
(SELinux対応)
[root@freeipa-nfs ~]# semanage fcontext -a -t home_root_t /nfs/home
[root@freeipa-nfs ~]# restorecon -R  /nfs/home
[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)
#
#  krb5で接続させるなら
/nfs         gss/krb5(rw,sync,sec=krb5,fsid=0)
/nfs/home    gss/krb5(rw,sync,sec=krb5,nohide)
/nfs/apps    gss/krb5(rw,sync,sec=krb5,nohide)
 
[root@freeipa-nfs ~]# systemctl enable nfs-server --now

あとfirewallに穴をあける

[root@freeipa-nfs ~]# firewall-cmd --add-service=nfs --permanent --zone=public
[root@freeipa-nfs ~]# firewall-cmd --reload

freeipaサーバにてautomount mapを作る

freeipaサーバでの作業です. 「nis automount」のようにautofsが効くようにします

FreeIPAドメインを作った時に既に用意されているlocationがあり、名前は「default」です

[root@freeipa ~]# ipa automountlocation-find
(略
  Location: default
(略
[root@freeipa ~]#

このlocation「default」で持っているmapは下記のように「auto.master」と「auto.direct」です.

[root@freeipa ~]# ipa automountmap-find default
(略
  Map: auto.direct
 
  Map: auto.master
(略
[root@freeipa ~]#

っで既定で用意されていたこの「auto.master」と「auto.direct」の中身は「ipa automountkey-find」で読めて

[root@freeipa ~]# ipa automountkey-find default auto.master
-----------------------
1 automount key matched
-----------------------
  Key: /-
  Mount information: auto.direct
----------------------------
Number of entries returned 1
----------------------------
 
[root@freeipa ~]# ipa automountkey-find default auto.direct
------------------------
0 automount keys matched
------------------------
----------------------------
Number of entries returned 0
----------------------------
[root@freeipa ~]#

っと、「auto.master」の中身は /etc/auto.master で例えれば

/- auto.direct

な感じ. っでauto.directの中身は今はない状態. っで例えば auto.directマップ に/etc/auto.homeな下記のデータを載せるなら.

/home       -rw freeipa-nfs:/home
/apps       -rw freeipa-nfs:/apps

下記コマンドを実行します.

[root@freeipa ~]# ipa automountkey-add default auto.direct --key="/home" --info="-rw,sec=krb5 freeipa-nfs:/home"       <-- /homeをkrb5で認証させます
[root@freeipa ~]# ipa automountkey-add default auto.direct --key="/apps" --info="-rw,sec=krb5 freeipa-nfs:/apps"
 
(確認)
[root@freeipa ~]# ipa automountkey-find default auto.direct
------------------------
2 automount keys matched
------------------------
  Key: /apps
  Mount information: -rw freeipa-nfs:/apps
 
  Key: /home
  Mount information: -rw freeipa-nfs:/home
----------------------------
Number of entries returned 2
----------------------------
[root@freeipa ~]#

修正の場合は下記のようにします. 下記は「/home -rw,nfs4,sec=sys freeipa-nfs:/home」にします. 「/apps」はそのままです

[root@freeipa ~]# ipa automountkey-mod default auto.direct --key="/home" --info="-rw freeipa-nfs:/home" --newinfo="-rw,sec=sys freeipa-nfs:/home"
[root@freeipa ~]# ipa automountkey-mod default auto.direct --key="/apps" --info="-rw freeipa-nfs:/apps" --newinfo="-rw,sec=sys freeipa-nfs:/apps"

「sec=krb5」の意味

krbチケットがないとmountできません.
代わりに「sec=sys」ならuid/gidでmountしてその場所に行けますが、uid/gidが偽装されたら他人の場所に入れてしまいます. 野良のnfs-clientがあれば参照されてしまいます.
よりセキュアなnfs環境となるとこの「sec=krb5」で行うのが望ましいかと.

krbチケットは認証しないと貰えませんから.

「/etc/exports」でmount可能なipを指定して阻止、MACアドレス制限とかありますが、偽装可能なので気休めなのかも

ユーザのホームディレクトリを作成

クライアント参加時の「ipa-client-install」にオプションとして「--mkhomedir」を加えれば勝手にホームディレクトリを
作ってくれるけど、それがnfs先、しかもautofsでもできるの?確かめていない。
っで、nfsサーバで作る

[root@freeipa-nfs ~]# mkhomedir_helper arcueid 0022 /etc/skel
[root@freeipa-nfs ~]# mkhomedir_helper illya   0022 /etc/skel
 
[root@freeipa-nfs ~]# ls -l /home
total 0
drwxr-xr-x. 2 arcueid em 62 Apr 29 22:22 arcueid
drwxr-xr-x. 2 illya   em 62 Apr 29 22:22 illya
[root@freeipa-nfs ~]#

作れなかったら原因はSELinuxかも. 「restorecon -R /home/」で調整してみる

最新の60件
2025-07-13 2025-07-12 2025-07-11 2025-07-05 2025-07-02 2025-07-01 2025-06-29 2025-06-24 2025-06-23 2025-06-21 2025-06-18 2025-06-15 2025-06-14 2025-06-11 2025-06-09 2025-06-08 2025-06-07 2025-06-05 2025-06-02 2025-06-01 2025-05-31 2025-05-30 2025-05-25 2025-05-22 2025-05-21 2025-05-20 2025-05-18 2025-05-17 2025-05-14
  • FreeIPA/nfs
2025-05-13 2025-05-12 2025-05-11 2025-05-08 2025-05-07 2025-05-06 2025-05-05 2025-05-04 2025-05-03

edit


トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2025-05-14 (水) 03:48:55