📄 1880.html
字号:
dn: cn=Tux P Tuxedo,dc=carlasworld,dc=net<br>
cn: Tux P Tuxedo<br>
cn: Tux Tuxedo<br>
objectClass: person<br>
sn: Tuxedo<br>
太棒了!他真的有用,它真的有用!注意:原来的.ldif 文件内不能有条目,因为它必须只包含新条目。如果ldapadd 找到任何现有的条目,它就会停止,不推进更多的条目。<br>
Debian 的差别<br>
如果你使用apt-get安装OpenLDAP,,dpkg将自动配置它,安装root域、公司以及授权的ldap管理员和密码。你也可以在slapd.conf中创建另外一个LDAP管理员/密码组,就像我们前面做过的一样,任意使用其中一个。<br>
模式<br>
我们容易混淆的主要地方是schema 和object classes。在slapd.conf中可以看到:<br>
# Schema and objectClass definitions<br>
include /etc/ldap/schema/core.schema<br>
include /etc/ldap/schema/cosine.schema<br>
include /etc/ldap/schema/nis.schema<br>
include /etc/ldap/schema/inetorgperson.schema<br>
这些文件包含用在你LDAP记录中的属性。花点时间读读这些属性。我知道这是一个痛苦的练习,但是理解模式就是理解如何使用LDAP的关键。<br>
现在是时候提到一个用于LDAP的GUI 前端GQ LDAP Client。他对于观察不同属性之间的关系大有帮助。优秀Web站点LDAPman Schema Reference 也是你观察时一个很有价值的工具。<br>
结论<br>
好,看起来好像我们还需要不止一篇LDAP文章。在part 4 中,我们将进行加密,认证真正的用户。我们将使用一些详细的配置范例来包装此文(和此系列)。【original text】<br>
Resources<br>
Building an LDAP Server on Linux, Part 1<br>
Building an LDAP Server on Linux, Part 2<br>
OpenLDAP Administrator's Guide<br>
GQ LDAP Client<br>
LDAPman Schema<br>
Reference page.<br>
在《在Linux上建立LDAP服务器(三)》我们使用真实数据来组装我们的目录,引导你毫无费力的避开一些常见误区。在本系列的最后一个安装部分,我们将讨论如何保护我们OpenLDAP服务器的安全。<br>
目录<br>
密码散列<br>
加密<br>
生成TLS证书<br>
重写slapd.conf<br>
迁移用户数据<br>
结论<br>
Resources<br>
我们先回顾一下,part1 介绍了轻型目录访问协议,细述了协议能做什么,不能做什么。part2 阐述了安装和非常基本的配置。 part3 展示了使用真实数据组装目录以及如何避免一些常见错误。<br>
今天的安全论述先从散列你的密码开始。<br>
密码散列<br>
我们不想将rootpw 存储在服务器上的明文内,所以我们改用散列。有几种普遍使用的散列方法可通过slappasswd 命令来实现,包括SHA、SSHA、MD5、和CRYPT在内。CRYPT最差,不要用它。SSHA是默认方法,MD5也不错。使用slappasswd 可以生成一个很好的散列rootpw:<br>
$ slappasswd<br>
New password:<br>
Re-enter new password:<br>
{SSHA}Lr7P++EoH6GpIS4GZ36vkV4R422RuW7R<br>
现在复制粘贴这个很好的新散列到/etc/ldap/slapd.conf内:<br>
rootpw {SSHA}Lr7P++EoH6GpIS4GZ36vkV4R422RuW7R<br>
这可以是一个永久设置,很适合用在小型的简单的LAN上。 更好的解决方案就是创建一个LDAP记录,该记录定义了LDAP管理员,还为LDAP管理员使用slapd.conf中的ACLs (access control lists)定义了访问权限。请看OpenLDAP管理员的指南中的重要章节chapter on ACLs ——它是我看到的关于ACLs的最好的指南。<br>
加密<br>
OpenLDAP 默认采用明文在网络上传送信息,包括密码和注册在内。加密可以防止中途截取和窃听。加密需要以下工具:<br>
OpenSSL<br>
Cyrus SASL<br>
这些在你的系统上应该有。如果没有,不妨先骂它两句,然后访问你的安装盘或者你的版本的Web站点,找到他们。在Debian上,寻找 libssl和libsasl;在基于RPM的系统上,寻找openssl、 cyrus-sasl、和cyrus-sasl-md5。(如果你在这一点上偏执的话,那就去吧。 LDAP相当复杂,所以偏执也是一种可以接受的正常行为。)<br>
生成TLS证书<br>
首先我们必须生成一张服务器证书。这是一张自我生成的仅供slapd 使用的证书。如果你不需要安装“认证机构”认证其他证书,也不需要某种信任的第三组织认证机构,如Thawte,这个方法够用了。<br>
在包含slapd.conf 的目录下运行下列命令。他将会产生一个新的X509 证书,不需要密码。他还将证书命名为slapd_cert.pem,密码命名为slapd_key.pem,并给与它一年的使用期限:<br>
root@windbag:/etc/ldap/# openssl req -new -x509 -nodes -out slapd_cert.pem -keyout slapd_key.pem -days 365<br>
Generating a 1024 bit RSA private key<br>
...........++++++<br>
...................++++++<br>
writing new private key to 'slapd_key.pem'<br>
然后它会向你提出一串问题。不要怕,一一回答他的问题好了。所有这两个文件都必须属于ldap 用户,该用户在Red Hat上称为'ldap.' (在Debian上叫做'root.')现在设定你的权限—— slapd_cert.pem 必须是全世界易懂的,slapd_key.pem 只有ldap 用户才可以读,不允许任何人写入。<br>
重写slapd.conf<br>
接下来我们需要告诉slapd 到哪里找到这些文件:<br>
database bdb<br>
# The base of your directory in database #1<br>
suffix "dc=carlasworld,dc=net"<br>
rootdn "cn=Metest,dc=carlasworld,dc=net"<br>
rootpw {SSHA}Lr7P++EoH6GpIS4GZ36vkV4R422RuW7R<br>
# Where the database file is physically stored for database #1<br>
directory "/var/lib/ldap"<br>
#Specify ciphers<br>
TLSCipherSuite HIGH:MEDIUM:+SSLv2:+SSLv3<br>
#TLS keyfile locations<br>
/etc/ldap/slapd_cert.pem<br>
/etc/ldap/slapd_key.pem<br>
你知道哪种密码采用哪种方式命名吗?首先看看你的your OpenSSL支持什么:<br>
$ openssl ciphers -v<br>
他将会产生一个长长的、让人印象深刻的列表。上面例子中使用的术语是通配符。HIGH 表示使用密码长度超过128位(MEDIUM = 128 bits)的所有密码。我相信我们都不想使用LOW,它只有56和64位那么长。(参考 OpenSSL.org,以找到更多此类信息)<br>
现在我们需要重新启动ldap监控程序。在Red Hat上,键入:<br>
# /etc/init.d/ldap restart<br>
在 Debian上键入:<br>
# /etc/init.d/slapd restart<br>
迁移用户数据<br>
PADL软件还提供了几种可爱的脚本来减轻组装LDAP目录的琐事。他们抽取了你现有的用户数据,创建更好的LDAP目录条。请在他们的站点上寻找“迁移工具”。然后,你需要编辑migrate_common.ph, 将你指定的网络设置包括进来。<br>
使用/etc/services 或者/etc/protocols 可能会打乱LDAP服务器,产生异常,这是毫无意义的。对于Linux来说这些异常是相当静态的,普遍的;你不需要让LDAP为他们所用。我们从迁移 /etc/passwd 和 /etc/group开始。我建议备份/etc/passwd和 /etc/group,然后在副本(migrate_group.pl, migrate_passwd.pl)上先运行恰当的脚本。<br>
他将会产生.ldif文件,检查该文件,确认他们是按你希望的方式完成。脚本使用起来轻而易举:<br>
# migrate_passwd.pl /etc/passwd passwd.ldif<br>
然后,采用平常的方式通过ldapadd添加.ldif文件到数据库内:<br>
# ldapadd -x -D "cn=Manager,dc=carlasworld,dc=net" -W -f passwd.ldif<br>
结论<br>
OpenLDAP是一个重要的程序。他也是非常复杂的。希望本系列能够帮助你获得最初的速度冲击,你现在已经有了可以运行的服务器,你可用它来进行测试或者学习。在Resources中,我列出了我能找到的最有用的资源,他们可帮助你理解最难的LDAP组件:模式、ACLs,和加密。<br>
我还建议你寻找你的Linux版本中包括的有用文档,因为每个版本安装和配置OpenLDAP以及其他设备如TLS和SASL的方法大不相同。<br>
Resources<br>
OpenSSL<br>
Cyrus SASL<br>
Building an Address Book with OpenLDAP<br>
Using OpenLDAP For Authentication; Revision 2<br>
– This is an excellent document that also teaches client configuration<br>
PADL Software<br>
Openldap.org
</FONT><br>
</TD>
</TR>
<TR>
<TD colSpan=2><FONT
class=middlefont></FONT><BR>
<FONT
class=normalfont>全文结束</FONT> </TD>
</TR>
<TR>
<TD background="images/dot.gif" tppabs="http://www.linuxhero.com/docs/images/dot.gif" colSpan=2
height=10></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV></TD>
<TD vAlign=top width="20%"
background="images/line.gif" tppabs="http://www.linuxhero.com/docs/images/line.gif" rowSpan=2>
<DIV align=center>
<table class=tableoutline cellspacing=1 cellpadding=4
width="100%" align=center border=0>
<tr class=firstalt>
<td noWrap background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif" colspan=2 height=21>
<font class=normalfont><b>所有分类</b></font></td>
</tr>
<tr class=secondalt> <td noWrap width=27%> <font class=normalfont>1:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type1.html" tppabs="http://www.linuxhero.com/docs/type1.html">非技术类</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>2:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type2.html" tppabs="http://www.linuxhero.com/docs/type2.html">基础知识</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>3:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type3.html" tppabs="http://www.linuxhero.com/docs/type3.html">指令大全</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>4:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type4.html" tppabs="http://www.linuxhero.com/docs/type4.html">shell</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>5:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type5.html" tppabs="http://www.linuxhero.com/docs/type5.html">安装启动</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>6:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type6.html" tppabs="http://www.linuxhero.com/docs/type6.html">xwindow</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>7:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type7.html" tppabs="http://www.linuxhero.com/docs/type7.html">kde</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>8:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type8.html" tppabs="http://www.linuxhero.com/docs/type8.html">gnome</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>9:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type9.html" tppabs="http://www.linuxhero.com/docs/type9.html">输入法类</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>10:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type10.html" tppabs="http://www.linuxhero.com/docs/type10.html">美化汉化</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>11:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type11.html" tppabs="http://www.linuxhero.com/docs/type11.html">网络配置</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>12:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type12.html" tppabs="http://www.linuxhero.com/docs/type12.html">存储备份</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>13:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type13.html" tppabs="http://www.linuxhero.com/docs/type13.html">杂项工具</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>14:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type14.html" tppabs="http://www.linuxhero.com/docs/type14.html">编程技术</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>15:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type15.html" tppabs="http://www.linuxhero.com/docs/type15.html">网络安全</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>16:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type16.html" tppabs="http://www.linuxhero.com/docs/type16.html">内核技术</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>17:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type17.html" tppabs="http://www.linuxhero.com/docs/type17.html">速度优化</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>18:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type18.html" tppabs="http://www.linuxhero.com/docs/type18.html">apache</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>19:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type19.html" tppabs="http://www.linuxhero.com/docs/type19.html">email</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>20:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type20.html" tppabs="http://www.linuxhero.com/docs/type20.html">ftp服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>21:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type21.html" tppabs="http://www.linuxhero.com/docs/type21.html">cvs服务</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>22:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type22.html" tppabs="http://www.linuxhero.com/docs/type22.html">代理服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>23:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type23.html" tppabs="http://www.linuxhero.com/docs/type23.html">samba</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>24:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type24.html" tppabs="http://www.linuxhero.com/docs/type24.html">域名服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>25:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type25.html" tppabs="http://www.linuxhero.com/docs/type25.html">网络过滤</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>26:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type26.html" tppabs="http://www.linuxhero.com/docs/type26.html">其他服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>27:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type27.html" tppabs="http://www.linuxhero.com/docs/type27.html">nfs</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>28:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type28.html" tppabs="http://www.linuxhero.com/docs/type28.html">oracle</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>29:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type29.html" tppabs="http://www.linuxhero.com/docs/type29.html">dhcp</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>30:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type30.html" tppabs="http://www.linuxhero.com/docs/type30.html">mysql</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>31:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type31.html" tppabs="http://www.linuxhero.com/docs/type31.html">php</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>32:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type32.html" tppabs="http://www.linuxhero.com/docs/type32.html">ldap</a></font></td> </tr> </table></td></tr> </table>
</DIV></TD></TR>
<TR vAlign=top>
<TD width="80%">
<DIV align=center><BR>
</DIV>
</TD></TR></TBODY></TABLE></TD></TR>
</TABLE></TD></TR>
</TABLE>
<TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#eeeeee
border=0><TBODY>
<TR>
<TD width="50%">
<P><FONT class=middlefont>版权所有 © 2004 <A
href="mailto:bjchenxu@sina.com">linux知识宝库</A><BR>
违者必究. </FONT></P>
</TD>
<TD width="50%">
<DIV align=right><FONT class=middlefont>Powered by: <A
href="mailto:bjchenxu@sina.com">Linux知识宝库</A> Version 0.9.0 </FONT></DIV>
</TD></TR></TBODY></TABLE>
<CENTER></CENTER></TD></TR>
</TABLE></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -