服务器 频道

存储入门基础:HP-UX安全手册

    二、安全安装HP-UX

    1、 建议在安装配置过程中,不要连接到任何不信任的网络中。

    2、 尽可能选择最小安装

    3、 尽可能不要安装NFS, X window, SNMP等组件(视具体需求而定)

    4、 安装完毕,则使用系统命令查看状态。

    # uname ?Ca (版本信息)

    # bdf (逻辑卷状态)

    # ps ?Cef (进程状态)

    # netstat -anf inet (端口状态)

    5、 安装各种驱动等

    6、 安装最新的补丁。

    http://us.itrc.hp.com

    安装补丁时要注意HP的补丁与硬件类型和系统版本都相关,检查并安装所有需要的补丁。确认需要swlist -l fileset.

    三、系统基本配置

    操作系统安装并打上补丁后,需要做一些措施来对系统进行一些配置。

    删除保存的补丁(可选)

    缺省情况下,补丁安装完会在/var/adm/sw/save/下备份所有的补丁。可以选择删除这些补丁文件,但一旦删除就没法使用swremove卸载补丁了。

    # swmodify -x patch_commit=true ''*.*''

    转换为一个可信系统:

    # /usr/lbin/tsconvert 
    Creating secure password database... 
    Directories created. 
    Making default files. 
    System default file created... 
    Terminal default file created... 
    Device assignment file created... 
    Moving passwords... 
    secure password database installed. 
    Converting at and crontab jobs... 
    At and crontab files converted.

    改变全局特权

    HP-UX 有一个特权组,可以分配给一个组特权(参见privgrp(4)). 缺省情况下,CHOWN是分配给所有组的一个全局特权:

    $ getprivgrp 
    global privileges: CHOWN

    /sbin/init.d/set_prvgrp在系统启动时执行/usr/sbin/setprivgrp -f /etc /privgroup. 可以创建一个配置文件,删除所有的全局特权 (see setprivgrp(1m)):

    # getprivgrp 
    global privileges: CHOWN 
    # echo -n >/etc/privgroup 
    # chmod 400 /etc/privgroup 
    # /sbin/init.d/set_prvgrp start 
    # getprivgrp 
    global privileges:

    设置默认umask.

    转换到可信系统后,默认umask已经改为07077

    限制root远程登录,只能由console登录

    # echo console > /etc/securetty 
    # chmod 400 /etc/securetty

    打开inetd日志功能

    /etc/rc.config.d/netdaemons中的 INETD_ARGS 环境变量中增加-l参数:

    export INETD_ARGS=-l

    删除不需要的系统伪帐户

    # groupdel lp 
    # groupdel nuucp 
    # groupdel daemon 
    # userdel uucp 
    # userdel lp 
    # userdel nuucp 
    # userdel hpdb 
    # userdel www 
    # userdel daemon

    对于一些保留的系统伪帐户如:bin, sysadm, 应当将需要禁止帐户的**NP代替,并不提供登录shell

    Example: bin:NP:60002:60002:No Access User:/:/sbin/noshell

    root主目录从/改为/root.

    编辑/etc/passwd:

    root:*:0:3::/root:/sbin/sh

    创建目录并修改权限:

    # mkdir /root 
    # chmod 700 /root 
    # mv /.profile /root 
    # pwconv

    四、禁止网络服务

    1、禁止inetd 服务

    internet服务器过程inetd启动的网络服务是由两个配置文件/etc/inet/services /etc/inet/inetd.conf来配置的。/etc/inet/services文件指定每个服务的端口号和端口类型,该配置文件的部分示例如下:

    … 
    ftp 21/tcp 
    telnet 23/tcp 
    smtp 25/tcp mail 
    …

    /etc/inet/inetd.conf文件指定服务对应的系统服务程序,该配置文件部分示例如下:

    … 
    ftp stream tcp nowait root /usr/sbin/in.ftpd in.ftpd 
    telnet stream tcp nowait root /usr/sbin/in.telnetd in.telnetd 
    …

    当要停止某个服务,如ftptelnet等时,只要注释掉文件/etc/inet/services/etc/inet/inetd.conf中的相应条目,也就是在那一行的开头加上#字符,然后让inetd重新读配置文件,过程示例如下:

    # ps -ef |grep inetd 
    root 149 1 0 Jan 18 ? 0:00 /usr/sbin/inetd -s 
    root 24621 24605 0 15:53:01 pts/1 0:00 grep inetd 
    # kill ?CHUP 149

    以上第一条命令是为了获得inetd的进程号,示例中输出的第二列内容就是进程号(149),然后将该进程号填入第二条命令的相应位置。

    可以使用lsof ?Ci来查看监听进程和端口信息:

    # lsof -i 
    COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME 
    syslogd 261 root 5u inet 0x10191e868 0t0 UDP *:syslog (Idle) 
    rpcbind 345 root 4u inet 72,0x73 0t0 UDP *:portmap (Idle) 
    rpcbind 345 root 6u inet 72,0x73 0t0 UDP *:49158 (Idle) 
    rpcbind 345 root 7u inet 72,0x72 0t0 TCP *:portmap (LISTEN) 
    sendmail: 397 root 5u inet 0x10222b668 0t0 TCP *:smtp (LISTEN) 
    snmpdm 402 root 3u inet 0x10221a268 0t0 TCP *:7161 (LISTEN) 
    snmpdm 402 root 5u inet 0x10222a268 0t0 UDP *:snmp (Idle) 
    snmpdm 402 root 6u inet 0x10221f868 0t0 UDP *:* (Unbound) 
    mib2agt 421 root 0u inet 0x10223e868 0t0 UDP *:* (Unbound) 
    swagentd 453 root 6u inet 0x1019d3268 0t0 UDP *:2121 (Idle) 

    2、禁止其他服务

    防止syslogd网络监听

    安装PHCO_21023补丁可以给syslogd加上-N参数防止网络监听. 编辑/sbin/init.d/syslogd修改为 /usr/sbin/syslogd -DN.

    禁止SNMP服务

    编辑SNMP启动文件:

    /etc/rc.config.d/SnmpHpunix 
    Set SNMP_HPUNIX_START to 0: SNMP_HPUNIX_START=0 
    /etc/rc.config.d/SnmpMaster 
    Set SNMP_MASTER_START to 0: SNMP_MASTER_START=0 
    /etc/rc.config.d/SnmpMib2 
    Set SNMP_MIB2_START to 0: SNMP_MIB2_START=0 
    /etc/rc.config.d/SnmpTrpDst 
    Set SNMP_TRAPDEST_START to 0: SNMP_TRAPDEST_START=0

    禁止sendmail进程

    编辑/etc/rc.config.d/mailservs:

    export SENDMAIL_SERVER=0

    禁止rpcbind进程

    # rm /sbin/rc1.d/K600nfs.core 
    # rm /sbin/rc2.d/S400nfs.core 
    # mv /usr/sbin/rpcbind /usr/sbin/rpcbind.DISABLE

0
相关文章