📄 network-nis.html
字号:
<pre class="PROGRAMLISTING">+:::::::::</pre><p>with</p><pre class="PROGRAMLISTING">+@IT_EMP:::::::::</pre><p>Now, only the data for the users defined in the netgroup <varclass="REPLACEABLE">IT_EMP</var> is imported into <var class="REPLACEABLE">war</var>'spassword database and only these users are allowed to login.</p><p>Unfortunately, this limitation also applies to the ~ function of the shell and allroutines converting between user names and numerical user IDs. In other words, <ttclass="COMMAND">cd ~<var class="REPLACEABLE">user</var></tt> will not work, <ttclass="COMMAND">ls -l</tt> will show the numerical id instead of the username and <ttclass="COMMAND">find . -user joe -print</tt> will fail with ``<tt class="ERRORNAME">Nosuch user</tt>''. To fix this, you will have to import all user entries <spanclass="emphasis"><i class="EMPHASIS">without allowing them to login onto yourservers</i></span>.</p><p>This can be achieved by adding another line to <ttclass="FILENAME">/etc/master.passwd</tt>. This line should contain:</p><p><var class="LITERAL">+:::::::::/sbin/nologin</var>, meaning ``Import all entries butreplace the shell with <tt class="FILENAME">/sbin/nologin</tt> in the imported entries''.You can replace any field in the passwd entry by placing a default value in your <ttclass="FILENAME">/etc/master.passwd</tt>.</p><div class="WARNING"><blockquote class="WARNING"><p><b>Warning</b>Make sure that the line <varclass="LITERAL">+:::::::::/sbin/nologin</var> is placed after <varclass="LITERAL">+@IT_EMP:::::::::</var>. Otherwise, all user accounts imported from NISwill have /sbin/nologin as their login shell.</p></blockquote></div><p>After this change, you will only have to change one NIS map if a new employee joinsthe IT department. You could use a similar approach for the less important servers byreplacing the old <var class="LITERAL">+:::::::::</var> in their local version of <ttclass="FILENAME">/etc/master.passwd</tt> with something like this:</p><pre class="PROGRAMLISTING">+@IT_EMP:::::::::+@IT_APP:::::::::+:::::::::/sbin/nologin</pre><p>The corresponding lines for the normal workstations could be:</p><pre class="PROGRAMLISTING">+@IT_EMP:::::::::+@USERS:::::::::+:::::::::/sbin/nologin</pre><p>And everything would be fine until there is a policy change a few weeks later: The ITdepartment starts hiring interns. The IT interns are allowed to use the normalworkstations and the less important servers; and the IT apprentices are allowed to loginonto the main servers. You add a new netgroup IT_INTERN, add the new IT interns to thisnetgroup and start to change the config on each and every machine... As the old sayinggoes: ``Errors in centralized planning lead to global mess''.</p><p>NIS' ability to create netgroups from other netgroups can be used to preventsituations like these. One possibility is the creation of role-based netgroups. Forexample, you could create a netgroup called <var class="REPLACEABLE">BIGSRV</var> todefine the login restrictions for the important servers, another netgroup called <varclass="REPLACEABLE">SMALLSRV</var> for the less important servers and a third netgroupcalled <var class="REPLACEABLE">USERBOX</var> for the normal workstations. Each of thesenetgroups contains the netgroups that are allowed to login onto these machines. The newentries for your NIS map netgroup should look like this:</p><pre class="PROGRAMLISTING">BIGSRV IT_EMP IT_APPSMALLSRV IT_EMP IT_APP ITINTERNUSERBOX IT_EMP ITINTERN USERS</pre><p>This method of defining login restrictions works reasonably well if you can definegroups of machines with identical restrictions. Unfortunately, this is the exception andnot the rule. Most of the time, you will need the ability to define login restrictions ona per-machine basis.</p><p>Machine-specific netgroup definitions are the other possibility to deal with thepolicy change outlined above. In this scenario, the <ttclass="FILENAME">/etc/master.passwd</tt> of each box contains two lines starting with``+''. The first of them adds a netgroup with the accounts allowed to login onto thismachine, the second one adds all other accounts with <ttclass="FILENAME">/sbin/nologin</tt> as shell. It is a good idea to use the ALL-CAPSversion of the machine name as the name of the netgroup. In other words, the lines shouldlook like this:</p><pre class="PROGRAMLISTING">+@<var class="REPLACEABLE">BOXNAME</var>:::::::::+:::::::::/sbin/nologin</pre><p>Once you have completed this task for all your machines, you will not have to modifythe local versions of <tt class="FILENAME">/etc/master.passwd</tt> ever again. Allfurther changes can be handled by modifying the NIS map. Here is an example of a possiblenetgroup map for this scenario with some additional goodies.</p><pre class="PROGRAMLISTING"># Define groups of users firstIT_EMP (,alpha,test-domain) (,beta,test-domain)IT_APP (,charlie,test-domain) (,delta,test-domain)DEPT1 (,echo,test-domain) (,foxtrott,test-domain)DEPT2 (,golf,test-domain) (,hotel,test-domain)DEPT3 (,india,test-domain) (,juliet,test-domain)ITINTERN (,kilo,test-domain) (,lima,test-domain)D_INTERNS (,able,test-domain) (,baker,test-domain)## Now, define some groups based on rolesUSERS DEPT1 DEPT2 DEPT3BIGSRV IT_EMP IT_APPSMALLSRV IT_EMP IT_APP ITINTERNUSERBOX IT_EMP ITINTERN USERS## And a groups for a special tasks# Allow echo and golf to access our anti-virus-machineSECURITY IT_EMP (,echo,test-domain) (,golf,test-domain)## machine-based netgroups# Our main serversWAR BIGSRVFAMINE BIGSRV# User india needs access to this serverPOLLUTION BIGSRV (,india,test-domain)## This one is really important and needs more access restrictionsDEATH IT_EMP## The anti-virus-machine mentioned aboveONE SECURITY## Restrict a machine to a single userTWO (,hotel,test-domain)# [...more groups to follow]</pre><p>If you are using some kind of database to manage your user accounts, you should beable to create the first part of the map with your database's report tools. This way, newusers will automatically have access to the boxes.</p><p>One last word of caution: It may not always be advisable to use machine-basednetgroups. If you are deploying a couple of dozen or even hundreds of identical machinesfor student labs, you should use role-based netgroups instead of machine-based netgroupsto keep the size of the NIS map within reasonable limits.</p></div><div class="SECT2"><h2 class="SECT2"><a id="AEN27462" name="AEN27462">19.9.8. Important Things toRemember</a></h2><p>There are still a couple of things that you will need to do differently now that youare in an NIS environment.</p><ul><li><p>Every time you wish to add a user to the lab, you must add it to the master NIS server<span class="emphasis"><i class="EMPHASIS">only</i></span>, and <span class="emphasis"><iclass="EMPHASIS">you must remember to rebuild the NIS maps</i></span>. If you forget todo this, the new user will not be able to login anywhere except on the NIS master. Forexample, if we needed to add a new user ``jsmith'' to the lab, we would:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">pw useradd jsmith</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">cd /var/yp</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">make test-domain</kbd></pre><p>You could also run <tt class="COMMAND">adduser jsmith</tt> instead of <ttclass="COMMAND">pw useradd jsmith</tt>.</p></li><li><p><span class="emphasis"><i class="EMPHASIS">Keep the administration accounts out of theNIS maps</i></span>. You do not want to be propagating administrative accounts andpasswords to machines that will have users that should not have access to thoseaccounts.</p></li><li><p><span class="emphasis"><i class="EMPHASIS">Keep the NIS master and slave secure, andminimize their downtime</i></span>. If somebody either hacks or simply turns off thesemachines, they have effectively rendered many people without the ability to login to thelab.</p><p>This is the chief weakness of any centralized administration system. If you do notprotect your NIS servers, you will have a lot of angry users!</p></li></ul></div><div class="SECT2"><h2 class="SECT2"><a id="AEN27488" name="AEN27488">19.9.9. NIS v1 Compatibility</a></h2><p>FreeBSD's <b class="APPLICATION">ypserv</b> has some support for serving NIS v1clients. FreeBSD's NIS implementation only uses the NIS v2 protocol, however otherimplementations include support for the v1 protocol for backwards compatibility witholder systems. The <b class="APPLICATION">ypbind</b> daemons supplied with these systemswill try to establish a binding to an NIS v1 server even though they may never actuallyneed it (and they may persist in broadcasting in search of one even after they receive aresponse from a v2 server). Note that while support for normal client calls is provided,this version of ypserv does not handle v1 map transfer requests; consequently, it cannotbe used as a master or slave in conjunction with older NIS servers that only support thev1 protocol. Fortunately, there probably are not any such servers still in use today.</p></div><div class="SECT2"><h2 class="SECT2"><a id="NETWORK-NIS-SERVER-IS-CLIENT"name="NETWORK-NIS-SERVER-IS-CLIENT">19.9.10. NIS Servers That Are Also NISClients</a></h2><p>Care must be taken when running ypserv in a multi-server domain where the servermachines are also NIS clients. It is generally a good idea to force the servers to bindto themselves rather than allowing them to broadcast bind requests and possibly becomebound to each other. Strange failure modes can result if one server goes down and othersare dependent upon it. Eventually all the clients will time out and attempt to bind toother servers, but the delay involved can be considerable and the failure mode is stillpresent since the servers might bind to each other all over again.</p><p>You can force a host to bind to a particular server by running <ttclass="COMMAND">ypbind</tt> with the <var class="OPTION">-S</var> flag. If you do notwant to do this manually each time you reboot your NIS server, you can add the followinglines to your <tt class="FILENAME">/etc/rc.conf</tt>:</p><pre class="PROGRAMLISTING">nis_client_enable="YES" # run client stuff as wellnis_client_flags="-S <var class="REPLACEABLE">NIS domain</var>,<varclass="REPLACEABLE">server</var>"</pre><p>See <span class="CITEREFENTRY"><span class="REFENTRYTITLE">ypbind</span>(8)</span> forfurther information.</p></div><div class="SECT2"><h2 class="SECT2"><a id="AEN27507" name="AEN27507">19.9.11. Password Formats</a></h2><p>One of the most common issues that people run into when trying to implement NIS ispassword format compatibility. If your NIS server is using DES encrypted passwords, itwill only support clients that are also using DES. For example, if you have <spanclass="TRADEMARK">Solaris</span> NIS clients in your network, then you will almostcertainly need to use DES encrypted passwords.</p><p>To check which format your servers and clients are using, look at <ttclass="FILENAME">/etc/login.conf</tt>. If the host is configured to use DES encryptedpasswords, then the <var class="LITERAL">default</var> class will contain an entry likethis:</p><pre class="PROGRAMLISTING">default:\ :passwd_format=des:\ :copyright=/etc/COPYRIGHT:\ [Further entries elided]</pre><p>Other possible values for the <var class="LITERAL">passwd_format</var> capabilityinclude <var class="LITERAL">blf</var> and <var class="LITERAL">md5</var> (for Blowfishand MD5 encrypted passwords, respectively).</p><p>If you have made changes to <tt class="FILENAME">/etc/login.conf</tt>, you will alsoneed to rebuild the login capability database, which is achieved by running the followingcommand as <tt class="USERNAME">root</tt>:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">cap_mkdb /etc/login.conf</kbd></pre><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> The format of passwords already in <ttclass="FILENAME">/etc/master.passwd</tt> will not be updated until a user changes theirpassword for the first time <span class="emphasis"><i class="EMPHASIS">after</i></span>the login capability database is rebuilt.</p></blockquote></div><p>Next, in order to ensure that passwords are encrypted with the format that you havechosen, you should also check that the <var class="LITERAL">crypt_default</var> in <ttclass="FILENAME">/etc/auth.conf</tt> gives precedence to your chosen password format. Todo this, place the format that you have chosen first in the list. For example, when usingDES encrypted passwords, the entry would be:</p><pre class="PROGRAMLISTING">crypt_default = des blf md5</pre><p>Having followed the above steps on each of the FreeBSD based NIS servers and clients,you can be sure that they all agree on which password format is used within your network.If you have trouble authenticating on an NIS client, this is a pretty good place to startlooking for possible problems. Remember: if you want to deploy an NIS server for aheterogenous network, you will probably have to use DES on all systems because it is thelowest common standard.</p></div></div><div class="NAVFOOTER"><hr align="LEFT" width="100%" /><table summary="Footer navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><td width="33%" align="left" valign="top"><a href="network-isdn.html"accesskey="P">Prev</a></td><td width="34%" align="center" valign="top"><a href="index.html"accesskey="H">Home</a></td><td width="33%" align="right" valign="top"><a href="network-dhcp.html"accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">ISDN</td><td width="34%" align="center" valign="top"><a href="advanced-networking.html"accesskey="U">Up</a></td><td width="33%" align="right" valign="top">DHCP</td></tr></table></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -