NIS をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
今更ながらnis
小規模で運用なら便利かな.
ただLinuxログインとsmb共有のパスワードが別々に管理される...
LDAPやsamba-ADのような大鉈よりは扱いいいかな. 他との連携...
ここでは極々簡単に
|BGCOLOR(YELLOW):役目|BGCOLOR(YELLOW):マシン名|BGCOLOR(YE...
|nis サーバ|nis|192.168.0.118|nfsサーバも兼ねる&br;提供ma...
|nis クライアント|nis-client|192.168.119||
&color(red){*};nisドメイン名: &color(magenta){sybyl};
rockylinux9でnis [[NIS/rockylinux9]]
rockylinux10でnis [[NIS/rockylinux10]]
***nisサーバ設置 [#r70fa59d]
nisドメイン名を定義します.
単純に「/etc/sysconfig/network」に定義します
#code(nonumber){{
[root@nis ~]# yum install ypserv
[root@nis ~]# echo "NISDOMAIN=sybyl" >> /etc/sysconfig/ne...
[root@nis ~]# reboot
(再起動後)
[root@nis ~]# domainname
sybyl
[root@nis ~]#
}}
提供サービスに合致する様に「/var/yp/Makefile」を修正する.
ここでは「passwd, group, hosts, autofs, netgroup」マップ...
Makefileを下記のように修正します.
#code(diff,nonumber){{
--- /var/yp/Makefile.orig 2019-08-09 12:26:57.00000...
+++ /var/yp/Makefile 2021-04-17 15:43:43.765427188 +0900
@@ -124,10 +124,7 @@
# If you don't want some of these maps built, feel free ...
# them out from this list.
-all: passwd group hosts rpc services netid protocols ma...
- # netgrp shadow publickey networks ethers bootpar...
- # amd.home auto.master auto.home auto.local passw...
- # timezone locale netmasks
+all: passwd group hosts netgrp auto.master auto.home
########################################################...
}}
該当するファイルは、/etc/passwd, /etc/group, /etc/hosts, ...
&color(white,blue){留意};
/etc/passwd, /etc/groupの全てのエントリーがnis共有される...
/etc/login.defsに記載の「UID_MIN」「GID_MIN」以下の値はni...
その後nisマスターへの下地を作ります
配布するデータの/etc/passwd, /etc/group, /etc/hostsは既定...
&size(10){これらファイルを欠けていると次のypinitでエラー...
#code(nonumber){{
[root@nis ~]# touch /etc/auto.master /etc/auto.home /etc/...
[root@nis ~]# /usr/lib64/yp/ypinit -h
usage:
ypinit -m
ypinit -s master
where -m is used to build the data bases on a master NIS ...
and -s is used for a slave data base. master must be an e...
reachable NIS server.
[root@nis ~]# /usr/lib64/yp/ypinit -m
At this point, we have to construct a list of the hosts w...
servers. nis.sybyl.local is in the list of NIS server ho...
the names for the other hosts, one per line. When you ar...
list, type a <control D>.
next host to add: nis.sybyl.local
next host to add: ...
The current list of NIS servers looks like this:
nis.sybyl.local
Is this correct? [y/n: y] y ...
We need a few minutes to build the databases...
Building /var/yp/sybyl/ypservers...
Running /var/yp/Makefile...
gmake[1]: Entering directory `/var/yp/sybyl'
Updating passwd.byname...
failed to send 'clear' to local ypserv: RPC: Program not ...
failed to send 'clear' to local ypserv: RPC: Program not ...
failed to send 'clear' to local ypserv: RPC: Program not ...
failed to send 'clear' to local ypserv: RPC: Program not ...
failed to send 'clear' to local ypserv: RPC: Program not ...
failed to send 'clear' to local ypserv: RPC: Program not ...
failed to send 'clear' to local ypserv: RPC: Program not ...
failed to send 'clear' to local ypserv: RPC: Program not ...
failed to send 'clear' to local ypserv: RPC: Program not ...
failed to send 'clear' to local ypserv: RPC: Program not ...
failed to send 'clear' to local ypserv: RPC: Program not ...
nis.sybyl.local has been set up as a NIS master server.
Now you can run ypinit -s nis.sybyl.local on all slave se...
[root@nis ~]#
}}
これで下準備は完了
firewallとかは[[https://access.redhat.com/documentation/j...
まずnisなのでrpcbindを許可する
#code(nonumber){{
[root@nis ~]# firewall-cmd --add-service=rpc-bind --zone=...
[root@nis ~]# firewall-cmd --reload
}}
そしてypservのサービスは 834、ypxfrdは 835、yppasswdは 83...
&size(10){番号は先の参照先から、yppasswdは単にその続き. ...
&size(10){ypservの834はrpc.statdと被る可能性があります. ...
#code(nonumber){{
[root@nis ~]# vi /etc/sysconfig/network
# Created by anaconda
NISDOMAIN=sybyl
YPSERV_ARGS="-p 834"
YPXFRD_ARGS="-p 835"
[root@nis ~]# vi /etc/sysconfig/yppasswdd
:
:
YPPASSWDD_ARGS="-e chsh -e chfn --port 836" <-...
[root@nis ~]#
}}
として
#code(nonumber){{
[root@nis ~]# firewall-cmd --add-port=834-836/tcp --add-p...
[root@nis ~]# firewall-cmd --reload
(確認)
[root@nis ~]# firewall-cmd --list-all --zone=public
public (active)
target: default
icmp-block-inversion: no
interfaces: ens192
sources:
services: dhcpv6-client rpc-bind ssh
ports: 834-836/tcp 834-836/udp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
[root@nis ~]#
}}
と反映させる.
っでサービスを開始させる
#code(nonumber){{
[root@nis ~]# systemctl enable yppasswdd.service ypserv.s...
}}
あとはコンテンツとなるマップを作成します.
***nisマップ作成 [#y473198b]
/etc/passwdや/etc/group、/etc/hostsは通常の使い方のままで...
それ以外の auto.master、auto.home、netgroupのマップを用意...
***auto.master [#cc2471f2]
nisクライアントが auto.master を参照するか否かはクライア...
そのnisクライアントで /etc/nsswitch.conf の automount項目が
#code(nonumber){{
automount: files nis
}}
なら、/etc/auto.masterを評価して次に nis の値を評価します.
ここでnisマスターサーバに於いて「auto.msater」には「Direc...
「Direct maps」方式は下記のように記載して、どのディレクト...
#code(nonumber){{
[root@nis ~]# cat /etc/auto.master
/- auto.home --timeout=60 --> auto.home マ...
[root@nis ~]#
(あるいはフィルを直に指定する)
[root@nis ~]# cat /etc/auto.master
/- /etc/auto.nfs --> ファイルシステ...
[root@nis ~]#
}}
&color(red){*};&size(10){全クライアントの/etc/auto.nfsを...
「Indirect maps」方式. ディレクトリ毎にマップを用意するなら
#code(nonumber){{
[root@nis ~]# cat /etc/auto.master
/home auto.home
/apps auto.apps
(あるいは)
/home /etc/auto.home
/apps /etc/auto.apps
[root@nis ~]#
}}
とします.
***auto.home [#h83f5615]
「Direct maps」方式なら
#code(nonumber){{
[root@nis ~]# cat /etc/auto.home
/home -rw,proto=tcp,nfsvers=3 nfs:/home
/apps -rw,proto=tcp,nfsvers=3 nfs:/apps
(あるいは)
/home/illya -rw,proto=tcp,nfsvers=3 nfs:/home/illya
/home/saber -rw,proto=tcp,nfsvers=3 nfs:/home/saber
/apps -rw,proto=tcp,nfsvers=3 nfs:/apps
[root@nis ~]#
}}
「Indirect maps」方式なら
#code(nonumber){{
[root@nis ~]# cat /etc/auto.home
illya -rw,proto=tcp,nfsvers=3 nis:/home/illya
saber -rw,proto=tcp,nfsvers=3 nis:/home/saber
[root@nis ~]#
}}
&size(10){/etc/auto.homeを書き換えてmakeした後で、全クラ...
***netgroup [#s6e171dc]
「 (host, user, domain) 」で定義されます。
利用場所は /etc/passwd の最終行に「+@sybyl-users」と加え...
nfsサーバにて/etc/exportsに
#code(nonumber){{
/home @sybyl-hosts(rw)
}}
とするとnetgroupで定義された「sybyl-hosts」のホスト限定で...
&color(red){*};&size(10){nfsサーバがnisクライアントになる...
っで具体的な作り方ですが
#code(nonumber){{
[root@nis ~]# cat /etc/netgroup
sybyl-users \
(-,illya,sybyl) (-,saber,sybyl)
sybyl-hosts \
(nis-client01,-,sybyl) (nis-client02,-,sybyl) \
(nis-client03,-,sybyl) (nis-client04,-,sybyl) \
(nis-client05,-,sybyl)
[root@nis ~]#
}}
な感じです
&color(red){*};&size(10){netgroupを/etc/passwdで使うには ...
***nfs設定 [#vdba0803]
「netgroup」を使った方法もあるがまずは、通常方法で
#code(nonumber){{
[root@nfs ~]# yum install nfs-utils
[root@nfs ~]# cat /etc/exports
/apps 192.168.0.0/255.255.255.0(rw,no_root_squash)
/home 192.168.0.0/255.255.255.0(rw,no_root_squash)
[root@nfs ~]# systemctl enable nfs-server && systemctl st...
[root@nfs ~]# firewall-cmd --permanent --zone=public --ad...
[root@nfs ~]# firewall-cmd --reload
}}
***nisアカウント作成 [#df5a057b]
単純にnisサーバ内で
#code(nonumber){{
[root@nis ~]# useradd -m -d /home/illya illya
}}
とかで作ります。その後にnisマップにするために
#code(nonumber){{
[root@nis ~]# cd /var/yp
[root@nis yp]# make
}}
とします。これで参加全ノードでアカウントが共有されます
***nisクライアントになるには [#a8c607b8]
#code(nonumber){{
[root@nis-client ~]# yum -y install ypbind autofs nfs-utils
[root@nis-client ~]# authconfig --enablenis --nisdomain=s...
[root@nis-client ~]# systemctl enable autofs
[root@nis-client ~]# systemctl start autofs
(SELinuxが有効なら)
[root@nis-client ~]# setsebool -P use_nfs_home_dirs 1
}}
***nisでsudoできるユーザを管理する [#y408aa9a]
「/etc/sudoers」を確認すると「wheel」グループに所属するユ...
&color(red){*};&size(10){ubuntuでは sudo グループ に所属...
#code(nonumber){{
%wheel ALL=(ALL) ALL
}}
またこのwheelグループのGIDを調べると
#code(nonumber){{
[root@nis ~]# getent group | grep wheel
wheel:x:10:
[root@nis ~]#
}}
と既に存在してGID:10である。「/var/yp/Makefile」を確認す...
このwheelのGID:10を弄って GID:1000 とかにすれば伝播可能な...
情報の参照順は「/etc/nsswitch.conf」で決まっていて、
#code(nonumber){{
[root@nis-client ~]# grep ^group /etc/nsswitch.conf
group: files nis sss
[root@nis-client ~]#
}}
と「/etc/group」を評価して、次にnisを評価している。
nis配下の計算機がCentOSなら「/etc/group」で既にwheelが定...
方策としては、
1.wheelのGIDを1000以上にして、nis配下の各計算機の/etc/g...
2.管理用のgroupをGID:1000以上で新設して、nis配下の各計...
の2方向でしょうか。
***nisクライアント, ubuntu [#m5edc531]
#code(nonumber){{
apt install nis
vi /etc/yp.conf
vi /etc/nsswitch.conf
systemctl restart rpcbind nis
}}
#code(nonumber){{
apt install nfs-kernel-server autofs
}}
終了行:
今更ながらnis
小規模で運用なら便利かな.
ただLinuxログインとsmb共有のパスワードが別々に管理される...
LDAPやsamba-ADのような大鉈よりは扱いいいかな. 他との連携...
ここでは極々簡単に
|BGCOLOR(YELLOW):役目|BGCOLOR(YELLOW):マシン名|BGCOLOR(YE...
|nis サーバ|nis|192.168.0.118|nfsサーバも兼ねる&br;提供ma...
|nis クライアント|nis-client|192.168.119||
&color(red){*};nisドメイン名: &color(magenta){sybyl};
rockylinux9でnis [[NIS/rockylinux9]]
rockylinux10でnis [[NIS/rockylinux10]]
***nisサーバ設置 [#r70fa59d]
nisドメイン名を定義します.
単純に「/etc/sysconfig/network」に定義します
#code(nonumber){{
[root@nis ~]# yum install ypserv
[root@nis ~]# echo "NISDOMAIN=sybyl" >> /etc/sysconfig/ne...
[root@nis ~]# reboot
(再起動後)
[root@nis ~]# domainname
sybyl
[root@nis ~]#
}}
提供サービスに合致する様に「/var/yp/Makefile」を修正する.
ここでは「passwd, group, hosts, autofs, netgroup」マップ...
Makefileを下記のように修正します.
#code(diff,nonumber){{
--- /var/yp/Makefile.orig 2019-08-09 12:26:57.00000...
+++ /var/yp/Makefile 2021-04-17 15:43:43.765427188 +0900
@@ -124,10 +124,7 @@
# If you don't want some of these maps built, feel free ...
# them out from this list.
-all: passwd group hosts rpc services netid protocols ma...
- # netgrp shadow publickey networks ethers bootpar...
- # amd.home auto.master auto.home auto.local passw...
- # timezone locale netmasks
+all: passwd group hosts netgrp auto.master auto.home
########################################################...
}}
該当するファイルは、/etc/passwd, /etc/group, /etc/hosts, ...
&color(white,blue){留意};
/etc/passwd, /etc/groupの全てのエントリーがnis共有される...
/etc/login.defsに記載の「UID_MIN」「GID_MIN」以下の値はni...
その後nisマスターへの下地を作ります
配布するデータの/etc/passwd, /etc/group, /etc/hostsは既定...
&size(10){これらファイルを欠けていると次のypinitでエラー...
#code(nonumber){{
[root@nis ~]# touch /etc/auto.master /etc/auto.home /etc/...
[root@nis ~]# /usr/lib64/yp/ypinit -h
usage:
ypinit -m
ypinit -s master
where -m is used to build the data bases on a master NIS ...
and -s is used for a slave data base. master must be an e...
reachable NIS server.
[root@nis ~]# /usr/lib64/yp/ypinit -m
At this point, we have to construct a list of the hosts w...
servers. nis.sybyl.local is in the list of NIS server ho...
the names for the other hosts, one per line. When you ar...
list, type a <control D>.
next host to add: nis.sybyl.local
next host to add: ...
The current list of NIS servers looks like this:
nis.sybyl.local
Is this correct? [y/n: y] y ...
We need a few minutes to build the databases...
Building /var/yp/sybyl/ypservers...
Running /var/yp/Makefile...
gmake[1]: Entering directory `/var/yp/sybyl'
Updating passwd.byname...
failed to send 'clear' to local ypserv: RPC: Program not ...
failed to send 'clear' to local ypserv: RPC: Program not ...
failed to send 'clear' to local ypserv: RPC: Program not ...
failed to send 'clear' to local ypserv: RPC: Program not ...
failed to send 'clear' to local ypserv: RPC: Program not ...
failed to send 'clear' to local ypserv: RPC: Program not ...
failed to send 'clear' to local ypserv: RPC: Program not ...
failed to send 'clear' to local ypserv: RPC: Program not ...
failed to send 'clear' to local ypserv: RPC: Program not ...
failed to send 'clear' to local ypserv: RPC: Program not ...
failed to send 'clear' to local ypserv: RPC: Program not ...
nis.sybyl.local has been set up as a NIS master server.
Now you can run ypinit -s nis.sybyl.local on all slave se...
[root@nis ~]#
}}
これで下準備は完了
firewallとかは[[https://access.redhat.com/documentation/j...
まずnisなのでrpcbindを許可する
#code(nonumber){{
[root@nis ~]# firewall-cmd --add-service=rpc-bind --zone=...
[root@nis ~]# firewall-cmd --reload
}}
そしてypservのサービスは 834、ypxfrdは 835、yppasswdは 83...
&size(10){番号は先の参照先から、yppasswdは単にその続き. ...
&size(10){ypservの834はrpc.statdと被る可能性があります. ...
#code(nonumber){{
[root@nis ~]# vi /etc/sysconfig/network
# Created by anaconda
NISDOMAIN=sybyl
YPSERV_ARGS="-p 834"
YPXFRD_ARGS="-p 835"
[root@nis ~]# vi /etc/sysconfig/yppasswdd
:
:
YPPASSWDD_ARGS="-e chsh -e chfn --port 836" <-...
[root@nis ~]#
}}
として
#code(nonumber){{
[root@nis ~]# firewall-cmd --add-port=834-836/tcp --add-p...
[root@nis ~]# firewall-cmd --reload
(確認)
[root@nis ~]# firewall-cmd --list-all --zone=public
public (active)
target: default
icmp-block-inversion: no
interfaces: ens192
sources:
services: dhcpv6-client rpc-bind ssh
ports: 834-836/tcp 834-836/udp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
[root@nis ~]#
}}
と反映させる.
っでサービスを開始させる
#code(nonumber){{
[root@nis ~]# systemctl enable yppasswdd.service ypserv.s...
}}
あとはコンテンツとなるマップを作成します.
***nisマップ作成 [#y473198b]
/etc/passwdや/etc/group、/etc/hostsは通常の使い方のままで...
それ以外の auto.master、auto.home、netgroupのマップを用意...
***auto.master [#cc2471f2]
nisクライアントが auto.master を参照するか否かはクライア...
そのnisクライアントで /etc/nsswitch.conf の automount項目が
#code(nonumber){{
automount: files nis
}}
なら、/etc/auto.masterを評価して次に nis の値を評価します.
ここでnisマスターサーバに於いて「auto.msater」には「Direc...
「Direct maps」方式は下記のように記載して、どのディレクト...
#code(nonumber){{
[root@nis ~]# cat /etc/auto.master
/- auto.home --timeout=60 --> auto.home マ...
[root@nis ~]#
(あるいはフィルを直に指定する)
[root@nis ~]# cat /etc/auto.master
/- /etc/auto.nfs --> ファイルシステ...
[root@nis ~]#
}}
&color(red){*};&size(10){全クライアントの/etc/auto.nfsを...
「Indirect maps」方式. ディレクトリ毎にマップを用意するなら
#code(nonumber){{
[root@nis ~]# cat /etc/auto.master
/home auto.home
/apps auto.apps
(あるいは)
/home /etc/auto.home
/apps /etc/auto.apps
[root@nis ~]#
}}
とします.
***auto.home [#h83f5615]
「Direct maps」方式なら
#code(nonumber){{
[root@nis ~]# cat /etc/auto.home
/home -rw,proto=tcp,nfsvers=3 nfs:/home
/apps -rw,proto=tcp,nfsvers=3 nfs:/apps
(あるいは)
/home/illya -rw,proto=tcp,nfsvers=3 nfs:/home/illya
/home/saber -rw,proto=tcp,nfsvers=3 nfs:/home/saber
/apps -rw,proto=tcp,nfsvers=3 nfs:/apps
[root@nis ~]#
}}
「Indirect maps」方式なら
#code(nonumber){{
[root@nis ~]# cat /etc/auto.home
illya -rw,proto=tcp,nfsvers=3 nis:/home/illya
saber -rw,proto=tcp,nfsvers=3 nis:/home/saber
[root@nis ~]#
}}
&size(10){/etc/auto.homeを書き換えてmakeした後で、全クラ...
***netgroup [#s6e171dc]
「 (host, user, domain) 」で定義されます。
利用場所は /etc/passwd の最終行に「+@sybyl-users」と加え...
nfsサーバにて/etc/exportsに
#code(nonumber){{
/home @sybyl-hosts(rw)
}}
とするとnetgroupで定義された「sybyl-hosts」のホスト限定で...
&color(red){*};&size(10){nfsサーバがnisクライアントになる...
っで具体的な作り方ですが
#code(nonumber){{
[root@nis ~]# cat /etc/netgroup
sybyl-users \
(-,illya,sybyl) (-,saber,sybyl)
sybyl-hosts \
(nis-client01,-,sybyl) (nis-client02,-,sybyl) \
(nis-client03,-,sybyl) (nis-client04,-,sybyl) \
(nis-client05,-,sybyl)
[root@nis ~]#
}}
な感じです
&color(red){*};&size(10){netgroupを/etc/passwdで使うには ...
***nfs設定 [#vdba0803]
「netgroup」を使った方法もあるがまずは、通常方法で
#code(nonumber){{
[root@nfs ~]# yum install nfs-utils
[root@nfs ~]# cat /etc/exports
/apps 192.168.0.0/255.255.255.0(rw,no_root_squash)
/home 192.168.0.0/255.255.255.0(rw,no_root_squash)
[root@nfs ~]# systemctl enable nfs-server && systemctl st...
[root@nfs ~]# firewall-cmd --permanent --zone=public --ad...
[root@nfs ~]# firewall-cmd --reload
}}
***nisアカウント作成 [#df5a057b]
単純にnisサーバ内で
#code(nonumber){{
[root@nis ~]# useradd -m -d /home/illya illya
}}
とかで作ります。その後にnisマップにするために
#code(nonumber){{
[root@nis ~]# cd /var/yp
[root@nis yp]# make
}}
とします。これで参加全ノードでアカウントが共有されます
***nisクライアントになるには [#a8c607b8]
#code(nonumber){{
[root@nis-client ~]# yum -y install ypbind autofs nfs-utils
[root@nis-client ~]# authconfig --enablenis --nisdomain=s...
[root@nis-client ~]# systemctl enable autofs
[root@nis-client ~]# systemctl start autofs
(SELinuxが有効なら)
[root@nis-client ~]# setsebool -P use_nfs_home_dirs 1
}}
***nisでsudoできるユーザを管理する [#y408aa9a]
「/etc/sudoers」を確認すると「wheel」グループに所属するユ...
&color(red){*};&size(10){ubuntuでは sudo グループ に所属...
#code(nonumber){{
%wheel ALL=(ALL) ALL
}}
またこのwheelグループのGIDを調べると
#code(nonumber){{
[root@nis ~]# getent group | grep wheel
wheel:x:10:
[root@nis ~]#
}}
と既に存在してGID:10である。「/var/yp/Makefile」を確認す...
このwheelのGID:10を弄って GID:1000 とかにすれば伝播可能な...
情報の参照順は「/etc/nsswitch.conf」で決まっていて、
#code(nonumber){{
[root@nis-client ~]# grep ^group /etc/nsswitch.conf
group: files nis sss
[root@nis-client ~]#
}}
と「/etc/group」を評価して、次にnisを評価している。
nis配下の計算機がCentOSなら「/etc/group」で既にwheelが定...
方策としては、
1.wheelのGIDを1000以上にして、nis配下の各計算機の/etc/g...
2.管理用のgroupをGID:1000以上で新設して、nis配下の各計...
の2方向でしょうか。
***nisクライアント, ubuntu [#m5edc531]
#code(nonumber){{
apt install nis
vi /etc/yp.conf
vi /etc/nsswitch.conf
systemctl restart rpcbind nis
}}
#code(nonumber){{
apt install nfs-kernel-server autofs
}}
ページ名:
1