新闻中心

EEPW首页 > 嵌入式系统 > 设计应用 > Linux安全配置步骤大全

Linux安全配置步骤大全

作者: 时间:2016-10-08 来源:网络 收藏

#manager: root ?remove or comment out.

#dumper: root ?remove or comment out.

#operator: root ?remove or comment out.

# trap decode to catch security attacks

#decode: root

# Person who should get roots mail

#root: marc

最后更新后不要忘记运行/usr/bin/newaliases,使改变生效。

9.阻止你的系统响应任何从外部/内部来的ping请求。

既然没有人能ping通你的机器并收到响应,你可以大大增强你的站点的安全性。你可以加下面的一行命令到/etc/rc.d/rc.local,以使每次启动后自动运行。

echo 1 >; /proc/sys/net/ipv4/icmp_echo_ignore_all

10. 不要显示出操作系统和版本信息。

如果你希望某个人远程登录到你的服务器时不要显示操作系统和版本信息,你能改变

/etc/inetd.conf中的一行象下面这样:

telnet stream tcp nowait root /usr/sbin/tcpd in.telnetd -h

加-h标志在最后使得telnet后台不要显示系统信息,而仅仅显示login:

11.The /etc/host.conf file

编辑host.conf文件(vi /etc/host.conf)且加下面的行:

# Lookup names via DNS first then fall back to /etc/hosts.

order bind,hosts

# We dont have machines with multiple IP addresses on the same card

(like virtual server,IP Aliasing).

multi off

# Check for IP address spoofing.

nospoof on

IP Spoofing: IP-Spoofing is a security exploit that works by tricking

computers in a trust relationship that you are someone that you really arent.

12. The /etc curetty file

该文件指定了允许root登录的tty设备,/etc curetty被/bin/login程序读取,它的

格式是一行一个被允许的名字列表,如你可以编辑/etc curetty且注释出下面的行。

tty1 #tty2 #tty3 #tty4 #tty5 #tty6 #tty7 #tty8

意味着root仅仅被允许在tty1终端登录。

13. 特别的帐号

禁止所有默认的被操作系统本身启动的且不需要的帐号,当你第一次装上系统时就应该做此检查,Linux提供了各种帐号,你可能不需要,如果你不需要这个帐号,就移走它,你有的帐号越多,就越容易受到攻击。

为删除你系统上的用户,用下面的命令:

[root@deep]# userdel username 为删除你系统上的组用户帐号,用下面的命令: [root@deep]# groupdel username 在终端上打入下面的命令删掉下面的用户。 [root@deep]# userdel adm [root@deep]# userdel lp [root@deep]# userdel sync [root@deep]# userdel shutdown [root@deep]# userdel halt [root@deep]# userdel mail 如果你不用sendmail服务器,procmail.mailx,就删除这个帐号。 [root@deep]# userdel news [root@deep]# userdel uucp [root@deep]# userdel operator [root@deep]# userdel games 如果你不用X windows 服务器,就删掉这个帐号。 [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 b curity/pam_rootok.so debug

auth required b curity/pam_wheel.so group=isd

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

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

[root@deep]# usermod -G10 admin

16. 资源限制

对你的系统上所有的用户设置资源限制可以防止DoS类型攻击(denial of service attacks)

如最大进程数,内存数量等。例如,对所有用户的限制象下面这样:

编辑/etc curity mits.con加: * hard core 0 * hard rss 5000 * hard nproc 20

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

session required b curity/pam_limits.so

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

17. The /etc lo.conf file

a) Add: restricted

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

b) Add: password=some_password

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

编辑/etc lo.conf加: boot=/dev/sda map=/boot/map install=/boot/boot.b prompt timeout=50 Default=linux restricted ?add this line. password=some_password ?add this line. image=/boot mlinuz-2.2.12-20 label=linux initrd=/boot/initrd-2.2.12-10.img root=/dev/sda6 read-only [root@deep]# chmod 600 /etc lo.conf (不再能被其他用户可读). [root@deep]# /sbin lo -v (更新lilo配置). [root@deep]# chattr +i /etc lo.conf(阻止该文件被修改)



关键词:

评论


相关推荐

技术专区

关闭