打印本文 打印本文 关闭窗口 关闭窗口
Linux 网络安全和优化
作者:武汉SEO闵涛  文章来源:敏韬网  点击数7905  更新时间:2009/4/22 20:47:29  文章录入:mintao  责任编辑:mintao
服务器,就删掉这个帐号。

[root@deep]# userdel gopher

[root@deep]# userdel ftp

如果你不允许匿名FTP,就删掉这个用户帐号。

打入下面的命令删除组帐号

[root@deep]# groupdel adm

[root@deep]# groupdel lp

[root@deep]# groupdel mail

如不用Sendmail服务器,删除这个组帐号

[root@deep]# groupdel news

[root@deep]# groupdel uucp

[root@deep]# groupdel games

如你不用X Windows,删除这个组帐号

[root@deep]# groupdel dip

[root@deep]# groupdel pppusers

[root@deep]# groupdel popusers

如果你不用POP服务器,删除这个组帐号

[root@deep]# groupdel slipusers

用下面的命令加需要的用户帐号

[root@deep]# useradd username

用下面的命令改变用户口令

[root@deep]# passwd username

chattr命令给下面的文件加上不可更改属性。

[root@deep]# chattr +i /etc/passwd

[root@deep]# chattr +i /etc/shadow

[root@deep]# chattr +i /etc/group

[root@deep]# chattr +i /etc/gshadow

14. 阻止任何人su作为root.

如果你不想任何人能够su作为root,你能编辑/etc/pam.d/su加下面的行:

auth sufficient /lib/security/pam_rootok.so debug

auth required /lib/security/pam_wheel.so group=isd 

意味着仅仅isd组的用户可以su作为root.

然后,如果你希望用户adminsu作为root.就运行下面的命令。

[root@deep]# usermod -G10 admin

15. 资源限制

对你的系统上所有的用户设置资源限制可以防止DoS类型攻击(denial of service attacks如最大进程数,内存数量等。例如,对所有用户的限制象下面这样:

编辑/etc/security/limits.con加: 

* hard core 0

* hard rss 5000

* hard nproc 20

你也必须编辑/etc/pam.d/login文件加/检查这一行的存在。

session required /lib/security/pam_limits.so

上面的命令禁止core files“core 0”,限制进程数为“nproc 50“,且限制内存使用

5M“rss 5000” 

16. The /etc/lilo.conf file

a) Add: restricted

加这一行到每一个引导映像下面,就这表明如果你引导时用(linux single),则需要一个password. 

b) Add: password=some_password

当与restricted联合用,且正常引导时,需要用户输入密码,你也要确保lilo.conf文件不能被不属于root的用户可读,也免看到密码明文。下面是例子:

编辑/etc/lilo.conf加:

boot=/dev/sda

map=/boot/map

install=/boot/boot.bprompt

timeout=50

Default=linux

restricted ?add this line.

password=some_password ?add this line.

image=/boot/vmlinuz-2.2.12-20

label=linux

initrd=/boot/initrd-2.2.12-10.img

root=/dev/sda6

read-only

[root@deep]# chmod 600 /etc/lilo.conf (不再能被其他用户可读).

[root@deep]# /sbin/lilo -v (更新lilo配置).

[root@deep]# chattr +i /etc/lilo.conf(阻止该文件被修改)

17. 禁止 Control-Alt-Delete 重启动机器命令

[root@deep]# vi /etc/inittab

ca::ctrlaltdel:/sbin/shutdown -t3 -r now

To

#ca::ctrlaltdel:/sbin/shutdown -t3 -r now

[root@deep]# /sbin/init q 

18. 重新设置/etc/rc.d/init.d/目录下所有文件的许可权限

[root@deep]# chmod -R 700 /etc/rc.d/init.d/*

仅仅root可以读,写,执行上述所有script file.

19. The /etc/rc.d/rc.local file

默认地,当你loginlinux server时,它告诉你linux版本名,内核版本名和服务器主机名。它给了你太多的信息,如果你就希望得到提示login: ,编辑/etc/rc.d/rc.local#在下面的行前面:

# This will overwrite /etc/issue at every boot. So, make any changes you

# want to make to /etc/issue here or you will lose them when you reboot.

#echo "" > /etc/issue

#echo "$R" >> /etc/issue

#echo "Kernel $(uname -r) on $a $(uname -m)" >> /etc/issue#

#cp -f /etc/issue /etc/issue.net

#echo >> /etc/issue

然后,做下面的事情:

[root@deep]# rm -f /etc/issue

[root@deep]# rm -f /etc/issue.net

[root@deep]# touch /etc/issue

[root@deep]# touch /etc/issue.net

20. root拥有的程序的位。

移走那些被root拥有程序的s位标志,当然有些程序需要这个,用命令‘chmod a-s’完成这个。

注:前面带(*)号的那些程序一般不需要拥有s位标志。

[root@deep]# find / -type f \( -perm -04000 -o -perm -02000 \) \-exec ls –lg {} \;

-rwsr-xr-x 1 root root 33120 Mar 21 1999 /usr/bin/at

*-rwsr-xr-x 1 root root 30560 Apr 15 20:03 /usr/bin/chage

*-rwsr-xr-x 1 root root 29492 Apr 15 20:03 /usr/bin/gpasswd

-rwsr-xr-x 1 root root 3208 Mar 22 1999 /usr/bin/disable-paste

-rwxr-sr-x 1 root man 32320 Apr 9 1999 /usr/bin/man

-r-s--x--x 1 root root 10704 Apr 14 17:21 /usr/bin/passwd

-rws--x--x 2 root root 517916 Apr 6 1999 /usr/bin/suidperl

-rws--x--x 2 root root 517916 Apr 6 1999 /usr/bin/sperl5.00503

-rwxr-sr-x 1 root mail 11432 Apr 6 1999 /usr/bin/lockfile

-rwsr-sr-x 1 root mail 64468 Apr 6 1999 /usr/bin/procmail

-rwsr-xr-x 1 root root 21848 Aug 27 11:06 /usr/bin/crontab

-rwxr-sr-x 1 root slocate 15032 Apr 19 14:55 /usr/bin/slocate

*-r-xr-sr-x 1 root tty 6212 Apr 17 11:29 /usr/bin/wall

*-rws--x--x 1 root root 14088 Apr 17 12:57 /usr/bin/chfn

*-rws--x--x 1 root root 13800 Apr 17 12:57 /usr/bin/chsh

*-rws--x--x 1 root root 5576 Apr 17 12:57 /usr/bin/newgrp

*-rwxr-sr-x 1 root tty 8392 Apr 17 12:57 /usr/bin/write

-rwsr-x--- 1 root squid 14076 Oct 7 14:48 /usr/lib/squid/pinger

-rwxr-sr-x 1 root utmp 15587 Jun 9 09:30 /usr/sbin/utempter

*-rwsr-xr-x 1 root root 5736 Apr 19 15:39 /usr/sbin/usernetctl

*-rwsr-xr-x 1 root bin 16488 Jul 6 09:35 /usr/sbin/traceroute

-rwsr-sr-x 1 root root 299364 Apr 19 16:38 /usr/sbin/sendmail

-rwsr-xr-x 1 root root 34131 Apr 16 18:49 /usr/libexec/pt_chown

-rwsr-xr-x 1 root root 13208 Apr 13 14:58 /bin/su

*-rwsr-xr-x 1 root root 52788 Apr 17 15:16 /bin/mount

*-rwsr-xr-x 1 root root 26508 Apr 17 20:26 /bin/umount

*-rwsr-xr-x 1 root root 17652 Jul 6 09:33 /bin/ping

-rwsr-xr-x 1 root root 20164 Apr 17 12:57 /bin/login

*-rwxr-sr-x 1 root root 3860 Apr 19 15:39 /sbin/netreport

-r-sr-xr-x 1 root root 46472 Apr 17 16:26 /sbin/pwdb_chkpwd

[root@deep]# chmod a-s /usr/bin/chage

[root@deep]# chmod a-s /usr/bin/gpasswd

[root@deep]# chmod a-s /usr/bin/wall

[root@deep]# chmod a-s /usr/bin/chfn

[root@deep]# chmod a-s /usr/bin/chsh

[root@deep]# chmod a-s /usr/bin/newgrp

[root@deep]# chmod a-s /usr/bin/write

[root@deep]# chmod a-s /usr/sbin/usernetctl

[root@deep]# chmod a-s /usr/sbin/traceroute

[root@deep]# chmod a-s /bin/mount

[root@deep]# chmod a-s /bin/umount

[root@deep]# chmod a-s /bin/ping

[root@deep]# chmod a-s /sbin/netreport 

你可以用下面的命令查找所有带

上一页  [1] [2] [3]  下一页

打印本文 打印本文 关闭窗口 关闭窗口