玩linux的第一步就是安装系统,不过在实际的生产环境中安装是有一定的要求的。接下来我用的工作经验跟大家交流一下RHEL4环境下的新系统安装事宜。绝对的原创。
安装第一步就是分区,以我工作的经验来说一般这样分:
/
8G
/var
8G
/usr
8G
/tmp
8
G
swap
4G(根据实际情况)
/home
剩余全部
第二步就是选择软件包,首先图形界面是绝对不能安装的,接下来所有的服务全部都不装。只把开发工具装上,记着要装上vim。这一块还是要看工作的要求,比如开发环境的要求。
先不要接通网线(外网不能通就行,留个内网然后去ssh管理)安装好后就要做安全优化。首先要运行一个安全脚本,这是关键,其实内容很简单,大家一看就明白。
cat << EOF >> /etc/profile
TMOUT=3600
export TMOUT
ulimit -n 65535
ulimit -u 14335
EOF
perl -i.ori -pe 's/^PASS_MIN_LEN
5/PASS_MIN_LEN
9/g' /etc/login.defs
cat << EOF >> /etc/sysctl.conf
net.ipv4.tcp_max_syn_backlog=1280
net.ipv4.tcp_syn_cookies=1
net.ipv4.conf.all.send_redirects=0
net.ipv4.conf.all.accept_redirects=0
net.ipv4.conf.all.accept_source_route=0
net.ipv4.conf.all.forwarding=0
net.ipv4.vs.timeout_timewait=60
net.ipv4.icmp_echo_ignore_broadcasts=1
fs.file-max=32768
EOF
useradd xmail
useradd dep
chkconfig --level 2345 nfs off
chkconfig --level 2345 netfs off
chkconfig --level 2345 nfslock off
chkconfig --level 2345 smartd off
chkconfig --level 2345 xinetd off
chkconfig --level 2345 rpcidmapd off
chkconfig --level 2345 openibd off
chkconfig --level 2345 messagebus off
chkconfig --level 2345 arptables_jf off
chkconfig --level 2345 readahead_early off
chkconfig --level 2345 mdmonitor off
chkconfig --level 2345 apmd off
chkconfig --level 2345 kudzu off
chkconfig --level 2345 autofs off
chkconfig --level 2345 rhnsd off
chkconfig --level 2345 gpm off
chkconfig --level 2345 xfs off
chkconfig --level 2345 pcmcia off
chkconfig --level 2345 irqbalance off
chkconfig --level 2345 microcode_ctl off
chkconfig --level 2345 rpcgssd off
chkconfig --level 2345 isdn off
chkconfig --level 2345 lm_sensors off
chkconfig --level 2345 rawdevices off
chkconfig --level 2345 haldaemon off
chkconfig --level 2345 portmap off
chkconfig --level 2345 lvm2-monitor off
chkconfig --level 2345 cups off
chkconfig --level 2345 sendmail off
chkconfig --level 2345 acpid off
service nfs stop
service netfs stop
service nfslock stop
service smartd stop
service xinetd stop
service rpcidmapd stop
service openibd stop
service messagebus stop
service arptables_jf stop
service readahead_early stop
service mdmonitor stop
service apmd stop
service kudzu stop
service autofs stop
service rhnsd stop
service gpm stop
service xfs stop
service pcmcia stop
service irqbalance stop
service microcode_ctl stop
service rpcgssd stop
service isdn stop
service lm_sensors stop
service rawdevices stop
service haldaemon stop
service portmap stop
service lvm2-monitor stop
service cups stop
service sendmail stop
service acpid stop
userdel adm
userdel lp
userdel sync
userdel mail
userdel news
userdel uucp
userdel operator
userdel games
userdel gopher
userdel ftp
userdel dbus
userdel vcsa
userdel netdump
userdel nscd
userdel rpc
userdel smmsp
userdel rpcuser
userdel nfsnobody
userdel pcap
userdel xfs
userdel pegasus
执行这个脚本。
因为RHEL4自带的ssh有漏洞所以要将其停掉,然后安装sshd2;将startup下的启动脚本拷贝到/etc/init.d/下,名为sshd2;将sshd2的文件拷贝到/usr/local/sbin/ssh2/下,并将本机自带的sshd关掉。修改sshd2的配置文件(在/etc下),使其只能监听本地端口(只有内网才能用sshd登陆)。
至此一台经过全面优化的相对安全的新系统就诞生了。