📄 39.html
字号:
#shell stream tcp nowait root /usr/sbin/tcpd in.rshd<br>
#login stream tcp nowait root /usr/sbin/tcpd in.rlogind<br>
#exec stream tcp nowait root /usr/sbin/tcpd in.rexecd<br>
#comsat dgram udp wait root /usr/sbin/tcpd in.comsat<br>
#talk dgram udp wait root /usr/sbin/tcpd in.talkd<br>
#ntalk dgram udp wait root /usr/sbin/tcpd in.ntalkd<br>
#dtalk stream tcp wait nobody /usr/sbin/tcpd in.dtalkd<br>
#<br>
# Pop and imap mail services et al<br>
#<br>
#pop-2 stream tcp nowait root /usr/sbin/tcpd ipop2d<br>
#pop-3 stream tcp nowait root /usr/sbin/tcpd ipop3d<br>
#imap stream tcp nowait root /usr/sbin/tcpd imapd<br>
#<br>
# The Internet UUCP service.<br>
#<br>
#uucp stream tcp nowait uucp /usr/sbin/tcpd /usr/lib/uucp/uucico -l<br>
#<br>
# Tftp service is provided primarily for booting. Most sites<br>
# run this only on machines acting as "boot servers." Do not uncomment<br>
# this unless you *need* it.<br>
#<br>
#tftp dgram udp wait root /usr/sbin/tcpd in.tftpd<br>
#bootps dgram udp wait root /usr/sbin/tcpd bootpd<br>
#<br>
# Finger, systat and netstat give out user information which may be<br>
# valuable to potential "system crackers." Many sites choose to disable<br>
# some or all of these services to improve security.<br>
#<br>
#finger stream tcp nowait root /usr/sbin/tcpd in.fingerd<br>
#cfinger stream tcp nowait root /usr/sbin/tcpd in.cfingerd<br>
#systat stream tcp nowait guest /usr/sbin/tcpd /bin/ps -auwwx<br>
#netstat stream tcp nowait guest /usr/sbin/tcpd /bin/netstat -f inet<br>
#<br>
# Authentication<br>
#<br>
#auth stream tcp nowait nobody /usr/sbin/in.identd in.identd -l -e -o<br>
#<br>
# End of inetd.conf<br>
注意:改变了“inetd.conf”文件之后,别忘了给inetd进程发一个SIGHUP信号(killall –HUP inetd)。<br>
[root@deep /root]# killall -HUP inetd<br>
第四步:<br>
为了保证“inetd.conf”文件的安全,可以用chattr命令把它设成不可改变。把文件设成不可改变的只要用下面的命令:<br>
[root@deep]# chattr +i /etc/inetd.conf<br>
这样可以避免“inetd.conf”文件的任何改变(意外或是别的原因)。一个有“i”属性的文件是不能被改动的:不能删除或重命名,不能创建这个文件的链接,不能往这个文件里写数据。只有系统管理员才能设置和清除这个属性。如果要改变inetd.conf文件,你必须先清除这个不允许改变的标志:<br>
[root@deep]# chattr -i /etc/inetd.conf<br>
但是对于诸如sendmail,named,www等服务,由于它们不象finger,telnet等服务,在请求到来时由inet守护进程启动相应的进程提供服务,而是在系统启动时,作为守护进程运行的。而对于redhat linux,提供了一个linuxconfig命令,可以通过它在图形界面下交互式地设置是否在启动时运行相关服务。也可以通过命令来设置是否启动时启动某个服务,如:[root@deep]# chkconfig –level 35 named off<br>
具体命令可以参考man chkconfig的说明。linux网络服务器配置基础(下)<br>
* /etc/hosts.allow文件<br>
但是对于telnet、ftp等服务,如果将其一同关闭,那么对于管理员需要远程管理时,将非常不方便。linux提供另外一种更为灵活和有效的方法来实现对服务请求用户的限制,从而可以在保证安全性的基础上,使可信任用户使用各种服务。Linux提供了一个叫TCP wrapper的程序。在大多数发布版本中该程序往往是缺省地被安装。利用TCP wrapper你可以限制访问前面提到的某些服务。而且TCP wrapper的记录文件记录了所有的企图访问你的系统的行为。通过last命令查看该程序的log,管理员可以获知谁曾经或者企图连接你的系统。<br>
在/etc目录下,有两个文件:hosts.deny hosts.allow 通过配置这两个文件,你可以指定哪些机器可以使用这些服务,哪些不可以使用这些服务。<br>
当服务请求到达服务器时,TCP wrapper就按照下列顺序查询这两个文件,直到遇到一个匹配为止:<br>
1.当在/etc/hosts.allow里面有一项与请求服务的主机地址项匹配,那么就允许该主机获取该服务<br>
2.否则,如果在/etc/hosts.deny里面有一项与请求服务的主机地址项匹配,就禁止该主机使用该项服务。<br>
3.如果相应的配置文件不存在,访问控制软件就认为是一个空文件,所以可以通过删除或者移走配置文件实现对清除所有设置。在文件中,空白行或者以#开头的行被忽略,你可以通过在行前加#实现注释功能。<br>
配置这两个文件是通过一种简单的访问控制语言来实现的,访问控制语句的基本格式为:<br>
程序名列表:主机名/IP地址列表。<br>
程序名列表指定一个或者多个提供相应服务的程序的名字,名字之间用逗号或者空格分割,可以在inetd.conf文件里查看提供相应服务的程序名:如上面的文件示例中,telent所在行的最后一项就是所需的程序名:in.telnetd。<br>
主机名/IP地址列表指定允许或者禁止使用该服务的一个或者多个主机的标识,主机名之间用逗号或空格分隔。程序名和主机地址都可以使用通配符,实现方便的指定多项服务和多个主机。<br>
linux提供了下面灵活的方式指定进程或者主机列表:<br>
1.一个以"."起始的域名串,如.amms.ac.cn,那么www.amms.ac.cn就和这一项匹配<br>
2.以"."结尾的IP串如202.37.152.那么IP地址包括202.37.152.的主机都与这一项匹配。<br>
3.格式为n.n.n.n/m.m.m.m表示网络/掩码,如果请求服务的主机的IP地址与掩码的位与的结果等于n.n.n.n,那么该主机与该项匹配。<br>
4.ALL表示匹配所有可能性<br>
5.EXPECT表示除去后面所定义的主机。如:list_1 EXCEPT list_2 表示list_1主机列表中除去List_2所列出的主机<br>
6.LOCAL表示匹配所有主机名中不包含"."的主机<br>
上面的几种方式只是linux提供的方式中的几种,但是对于我们的一般应用来说是足够了。我们通过举几个例子来说明这个问题:<br>
例一:我们只希望允许同一个局域网的机器使用服务器的ftp功能,而禁止广域网上面的ftp服务请求,本地局域网由202.39.154.、202.39.153.和202.39.152.三个网段组成。<br>
在hosts.deny文件中,我们定义禁止所有机器请求所有服务:<br>
ALL:ALL<br>
在hosts.allow文件中,我们定义只允许局域网访问ftp功能:<br>
in.ftpd -l –a: 202.39.154 202.39.153. 202.39.152.<br>
这样,当非局域网的机器请求ftp服务时,就会被拒绝。而局域网的机器可以使用ftp服务。此外,应该定期检查/var/log目录下的纪录文件,发现对系统安全有威胁的登录事件。last命令可以有效的查看系统登录事件,发现问题所在。<br>
最后tcpdchk是检查TCP_WAPPERS配置的程序。它检查TCP_WAPPERS的配置,并报告它可以发现的问题或潜在的问题。在所有的配置都完成了之后,请运行tcpdchk程序:<br>
[root@deep]# tcpdchk<br>
* /etc/services文件<br>
端口号和标准服务之间的对应关系在RFC 1700 “Assigned Numbers”中有详细的定义。“/etc/services”文件使得服务器和客户端的程序能够把服务的名字转成端口号,这张表在每一台主机上都存在,其文件名是“/etc/services”。只有“root”用户才有权限修改这个文件,而且在通常情况下这个文件是没有必要修改的,因为这个文件中已经包含了常用的服务所对应的端口号。为了提高安全性,我们可以给这个文件加上保护以避免没有经过授权的删除和改变。为了保护这个文件可以用下面的命令:<br>
[root@deep]# chattr +i /etc/services<br>
* /etc/securetty文件<br>
“/etc/securetty”文件允许你规定“root”用户可以从那个TTY设备登录。登录程序(通常是“/bin/login”)需要读取“/etc/securetty”文件。它的格式是:列出来的tty设备都是允许登录的,注释掉或是在这个文件中不存在的都是不允许root登录的。<br>
注释掉(在这一行的开头加上#号)所有你想不让root登录的tty设备。<br>
编辑securetty文件(vi /etc/securetty)象下面一样,注释掉一些行:<br>
tty1<br>
#tty2<br>
#tty3<br>
#tty4<br>
#tty5<br>
#tty6<br>
#tty7<br>
#tty8<br>
* 使Control-Alt-Delete关机键无效<br>
把“/etc/inittab”文件中的一行注释掉可以禁止用Control-Alt-Delete关闭计算机。如果服务器不是放在一个安全的地方,这非常重要。<br>
编辑inittab文件(vi /etc/inittab)把这一行:<br>
ca::ctrlaltdel:/sbin/shutdown -t3 -r now<br>
改为:<br>
#ca::ctrlaltdel:/sbin/shutdown -t3 -r now<br>
用下面的命令使改变生效:<br>
[root@deep]# /sbin/init q<br>
* 改变“/etc/rc.d/init.d/”目录下的脚本文件的访问许可<br>
/etc/rc.d/init.d/下的脚本主要包含了启动服务的脚本程序。一般用户没有什么必要知道脚本文件的内容。所以应该改变这些脚本文件的权限。<br>
[root@deep]# chmod -R 700 /etc/rc.d/init.d/*<br>
这样只有root可以读、写和执行这个目录下的脚本。<br>
* /etc/rc.d/rc.local文件<br>
在默认情况下,当登录装有linux系统的计算机时,系统会告诉你Linux发行版的名字、版本号、内核版本和服务器名称。这泄露了太多的系统信息。最好只显示一个“Login:”的提示信息。<br>
第一步:<br>
编辑“/ect/rc.d/rc.local”文件,在下面这些行的前面加上“#”:<br>
--<br>
# This will overwrite /etc/issue at every boot. So, make any changes you<br>
# want to make to /etc/issue here or you will lose them when you reboot.<br>
#echo "" > /etc/issue<br>
#echo "$R" >> /etc/issue<br>
#echo "Kernel $(uname -r) on $a $(uname -m)" >> /etc/issue<br>
#<br>
#cp -f /etc/issue /etc/issue.net<br>
#echo >> /etc/issue<br>
--<br>
第二步:<br>
删除“/etc”目录下的“issue.net”和“issue”文件:<br>
[root@deep]# rm -f /etc/issue<br>
[root@deep]# rm -f /etc/issue.net<br>
注意:“/etc/issue.net”文件是用户从网络登录计算机时(例如:telnet、SSH),看到的登录提示。同样在“”目录下还有一个“issue”文件,是用户从本地登录时看到的提示。这两个文件都是文本文件,可以根据需要改变。但是,如果想删掉这两个文件,必须象上面介绍的那样把“/etc/rc.d/rc.local”脚本中的那些行注释掉,否则每次重新启动的时候,系统又会重新创建这两个文件。
</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 + -