twbsd.org
 
  Select Language: Home  SmbFTPD Forum 

精華文章

VPN How-To

PHP 網頁修改系統密碼

Filtering Bridge (翻譯)

PHP從網頁傳遞變數的改變

NIS 伺服器

 


View printable page

VPN How-To

NIS 伺服器

NIS (Network Information System) 的目的是讓網路上許多台電腦共用一份使用者資料的設定資訊,有點類似 MS Windows NT domain。NIS 最早是由 SUN Microsystems 在其 SUN OS 中所使用,後來被廣為應用在各種的 UNIX 平台。以前 NIS 並不叫做 NIS,而是 YP (Yellow Pages),但後來因為商標問題才改為 NIS,但 YP 這個名字還是常被使用。例如,我們可以看到很多 NIS 所用的指令都是以 YP 為名。

當我們的系統中有多台伺服器時,若每一台伺服器上都要有相同的使用者設定,一種方法就是將每一台機器都維持同樣的設定,當我們要在新增一個使用者或使用者要修改密碼時,必須進入每一台機器做設定。另一種方式就是使用 NIS,我們只要設定其中一台為 NIS Master Server,其它的機器為 NIS Client,當需要修改設定時,我們只要在 Master server 做修改即可。

NIS 中有所謂 NIS domain 的觀念,Client 端可以加入某一個 NIS Domain 以使用該 NIS domain 的帳號密碼認証。以下我們的設定就以 domain "twbsd" 為範例。

NIS Server 的設定

首先,請修改 /etc/rc.conf 並加入下列設定:

rpcbind_enable="YES"
nisdomainname="twbsd"
nis_server_enable="YES"
nis_yppasswdd_enable="YES"
nis_yppasswdd_flags="-t /etc/master.passwd"
    

接下來請將 /var/yp/Makefile.dist 複製一份到 /var/yp/Makefile,並修改 /var/yp/Makefile 加入下列這一行並將 NOPUSH="True" 那一行註解掉:

#NOPUSH="True"
MASTER_PASSWD=/etc/master.passwd  

接下來請執行下列指令:

# ypinit -m twbsd
Creating an YP server will require that you answer a few questions.
Questions will all be asked at the beginning of the procedure.

Do you want this procedure to quit on non-fatal errors? [y/n: n]

Ok, please remember to go back and redo manually whatever fails.
If you don't, something might not work.

Can we destroy the existing /var/yp/twbsd and its contents? [y/n: n] y

At this point, we have to construct a list of this domains YP servers.
alexwang.com is already known as master server.
Please continue to add any slave servers, one per line. When you are
done with the list, type a <control D>.
      master server   :  alexwang.com
      next host to add:  ^D  如果還有其他的 slave server 則再加入,否則按 Ctrl+D
The current list of NIS servers looks like this:

alexwang.com
    

重新啟動 NIS Server 或請執行下列指令以啟動 NIS Server:

# /etc/netstart

NIS Client 的設定

在 Client 方面,請先編輯 /etc/rc.conf 並加入下列幾行:

rpcbind_enable="YES"
nisdomainname="twbsd"
nis_client_enable="YES"
nis_client_flags="-ypset -s -m -S twbsd,hostname-of-nis-server"

接下來請執行 vipw 修改 /etc/master.passwd 將非系統本身的使用者移除,並在檔案最後加入下列一行:

+:::::::::

接下來再編輯 /etc/group,將非系統本身的使用者移除,並加入這一行:

+:*::

接下來您應該就可以使用 ypcat passwd 來看到 Server 的 passwd map。

FreeBSD Handbook 中 NIS 的部份十份詳細,建議您參考該文件以獲得最多資訊。

 

Top Ths file was last modified: 2008 June 13 12:00:02.

Copyright © 2002-2024 Alex Wang from www.twbsd.org. All rights reserved.