NISサーバの環境ができたのでNISクライアントの設定を行います。
テスト環境
- NIS Server
- CentOS Linux release 7.2.1511 (Core)
- Linux host01.rootlinks.net 3.10.0-327.4.4.el7.x86_64
- NIS Client
- CentOS Linux release 7.2.1511 (Core)
- Linux host02.rootlinks.net 3.10.0-327.10.1.el7.x86_64
ypbind,yp-toolsのインストールを行います。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
[root@host02 ~]# yum install ypbind yp-tools Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: www.ftp.ne.jp * extras: www.ftp.ne.jp * updates: www.ftp.ne.jp Resolving Dependencies --> Running transaction check ---> Package yp-tools.x86_64 0:2.14-3.el7 will be installed ---> Package ypbind.x86_64 3:1.37.1-7.el7 will be installed --> Processing Dependency: rpcbind for package: 3:ypbind-1.37.1-7.el7.x86_64 --> Running transaction check ---> Package rpcbind.x86_64 0:0.2.0-33.el7_2 will be installed --> Processing Dependency: libtirpc.so.1()(64bit) for package: rpcbind-0.2.0-33.el7_2.x86_64 --> Running transaction check ---> Package libtirpc.x86_64 0:0.2.4-0.6.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ===================================================================================================================== Package Arch Version Repository Size ===================================================================================================================== Installing: yp-tools x86_64 2.14-3.el7 base 79 k ypbind x86_64 3:1.37.1-7.el7 base 62 k Installing for dependencies: libtirpc x86_64 0.2.4-0.6.el7 base 85 k rpcbind x86_64 0.2.0-33.el7_2 updates 57 k Transaction Summary ===================================================================================================================== Install 2 Packages (+2 Dependent packages) Total download size: 283 k Installed size: 570 k Is this ok [y/d/N]: y Downloading packages: (1/4): rpcbind-0.2.0-33.el7_2.x86_64.rpm | 57 kB 00:00:00 (2/4): libtirpc-0.2.4-0.6.el7.x86_64.rpm | 85 kB 00:00:00 (3/4): yp-tools-2.14-3.el7.x86_64.rpm | 79 kB 00:00:00 (4/4): ypbind-1.37.1-7.el7.x86_64.rpm | 62 kB 00:00:00 --------------------------------------------------------------------------------------------------------------------- Total 1.1 MB/s | 283 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : libtirpc-0.2.4-0.6.el7.x86_64 1/4 Installing : rpcbind-0.2.0-33.el7_2.x86_64 2/4 Installing : yp-tools-2.14-3.el7.x86_64 3/4 Installing : 3:ypbind-1.37.1-7.el7.x86_64 4/4 Verifying : rpcbind-0.2.0-33.el7_2.x86_64 1/4 Verifying : libtirpc-0.2.4-0.6.el7.x86_64 2/4 Verifying : yp-tools-2.14-3.el7.x86_64 3/4 Verifying : 3:ypbind-1.37.1-7.el7.x86_64 4/4 Installed: yp-tools.x86_64 0:2.14-3.el7 ypbind.x86_64 3:1.37.1-7.el7 Dependency Installed: libtirpc.x86_64 0:0.2.4-0.6.el7 rpcbind.x86_64 0:0.2.0-33.el7_2 Complete! |
1 2 3 4 5 6 7 |
[root@host02 ~]# ypdomainname rootlinks.net [root@host02 ~]# ypdomainname rootlinks.net [root@host02 ~]# echo "NISDOMAIN=rootlinks.net" >> /etc/sysconfig/network [root@host02 ~]# cat /etc/sysconfig/network # Created by anaconda NISDOMAIN=rootlinks.net |
1 2 3 4 5 |
[root@host02 ~]# vi /etc/hosts [root@host02 ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.1.1 host01.rootlinks.net host01 |
1 |
[root@host02 ~]# authconfig --enablenis --nisdomain=rootlinks.net --nisserver=host01.rootlinks.net --enablemkhomedir --update |
これでNIS認証の設定を行ってくれます。例えば/etc/nsswitch.confは
1 2 3 |
passwd: files sss shadow: files sss group: files sss |
が
1 2 3 |
passwd: files nis sss shadow: files nis sss group: files nis sss |
になります。これはローカルユーザ認証の次にNIS認証が行われます。
1 2 |
[root@host02 ~]# systemctl enable ypbind Created symlink from /etc/systemd/system/multi-user.target.wants/ypbind.service to /usr/lib/systemd/system/ypbind.service. |
SELinuxを無効にしているので警告が出ていますが動作には問題ないと思います。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[root@host02 ~]# systemctl start ypbind [root@host02 ~]# systemctl status ypbind * ypbind.service - NIS/YP (Network Information Service) Clients to NIS Domain Binder Loaded: loaded (/usr/lib/systemd/system/ypbind.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2016-03-15 17:28:35 JST; 5s ago Process: 2882 ExecStartPost=/usr/libexec/ypbind-post-waitbind (code=exited, status=0/SUCCESS) Process: 2874 ExecStartPre=/usr/sbin/setsebool allow_ypbind=1 (code=exited, status=1/FAILURE) Process: 2870 ExecStartPre=/usr/libexec/ypbind-pre-setdomain (code=exited, status=0/SUCCESS) Main PID: 2877 (ypbind) Status: "Processing requests..." CGroup: /system.slice/ypbind.service `-2877 /usr/sbin/ypbind -n Mar 15 17:28:34 host02.rootlinks.net systemd[1]: Starting NIS/YP (Network Information Service) Clients to NIS ...r... Mar 15 17:28:34 host02.rootlinks.net setsebool[2874]: setsebool: SELinux is disabled. Mar 15 17:28:35 host02.rootlinks.net systemd[1]: Started NIS/YP (Network Information Service) Clients to NIS D...der. Hint: Some lines were ellipsized, use -l to show in full. |
NISクライアントから動作確認をしてみます。
1 2 3 4 5 |
[root@host02 ~]# ypcat passwd user01:$6$xxxFb56294RSiZGPOvORhj.:1000:1000:user01:/home/user01:/bin/bash user02:$6$xxxtc.aUWBujXh6njbXl3F/:1001:1001:user02:/home/user02:/bin/bash [root@host02 ~]# ypwhich host01.rootlinks.net |