`

Linux + OS RedHat AS 5 Security

    博客分类:
  • OS
阅读更多

RedHat 安全管理

Q:  RedHat 5.3 x86_64   Fatal error...System Halted

Mouse not found
Keyboard not found
Fatal error... System Halted

A: 插上鼠标和键盘RedHat Linux系统又好了

 

-- 查看环境变量

[root@b2cbbs ~]# env

HOSTNAME=b2cbbs.s*****.cn
TERM=xterm
SHELL=/bin/bash
HISTSIZE=1000
SSH_CLIENT=172.17.25.104 1171 22
SSH_TTY=/dev/pts/4
USER=root
LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:
MAIL=/var/spool/mail/root
PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
INPUTRC=/etc/inputrc
PWD=/root
LANG=zh_CN.UTF-8
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
SHLVL=1
HOME=/root
LOGNAME=root
SSH_CONNECTION=172.17.25.104 1171 192.168.121.22 22
LESSOPEN=|/usr/bin/lesspipe.sh %s
DISPLAY=localhost:11.0
G_BROKEN_FILENAMES=1
_=/bin/env
[root@b2cbbs ~]#

 

http://shitou118.blog.51cto.com/715507/d-3

 

iptables相当好的视频教程

 

iptables防火墙设置视频演示 02(只允许某个端口访问)

http://www.17rumen.com/archives/54.html

[root@localhost ~]# services iptables stop

[root@localhost ~]# services iptables start

[root@localhost ~]# services iptables restart

在上次视频中,我简单的介绍了iptables的工作流程,还有如何
关闭所有端口和开放所有端口。

但是我们在配置服务器时候往往是只打开某个端口,其他的端口全部
关闭来提高我们服务器的安全性。

下面我就用端口22来举个例子如何实现,只允许端口22的访问 其他端口全部
都不能访问的, 端口22就是我们通过ssh来进行远程访问Linux默认端口。

看我现在服务器的情况:

通过命令 netstat -tnl 可以查看当前服务器打开了哪些端口

#redhat ssh远程连接 本机测试

[lindows@localhost tmp]$ ssh -l avatar 127.0.0.1
The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
RSA key fingerprint is ad:95:79:c8:f7:b5:3c:a4:ea:4e:1c:52:db:8e:ed:7f.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '127.0.0.1' (RSA) to the list of known hosts.
avatar@127.0.0.1's password:
Permission denied, please try again.
avatar@127.0.0.1's password:
Permission denied, please try again.
avatar@127.0.0.1's password:
Last login: Thu Nov 19 21:34:54 2009 from 172.17.25.104
[avatar@localhost ~]$

#redhat ssh远程连接ibm aix 机器

[root@localhost ~]# ssh  -l  siemens800 aix.unix-center.net

#查看网络端口使用情况

 

[root@localhost ~]# netstat -ptln

[root@localhost ~]# netstat -tnl

RedHat 安全管理

[root@localhost  ~]#iptables -L

[root@localhost  ~]#iptables -L  -n

[root@localhost  ~]#iptables --list

// 防火墙 INPUT FORWARD OUTPUT 三个部分全部是 ACCEPT 的,也就是没有做任何限制。

Chain INPUT (policy ACCEPT)
target     prot opt source               destination        
Chain FORWARD (policy ACCEPT)
target     prot opt source               destination        
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

下面我通过 putty.exe 这个软件来链接我的服务器,这个软件通过端口22来访问我们的Linux.

成功链接上去。这是理所当然成功的,以为Linux打开了22端口,而且Linux防火墙iptables 没有
做任何限制。

Redhat 防火墙关闭所有端口

[root@localhost  ~]# iptables -P INPUT DROP
[root@localhost  ~]# iptables -P FORWARD DROP
[root@localhost  ~]# iptables -P OUTPUT DROP

再查看一下 iptables -L -n

好成功关闭了所有端口。

 

192.168.100.99

 

[root@b2ccahce ~]# service iptables status
表格:filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination        
1    RH-Firewall-1-INPUT  all  --  0.0.0.0/0            0.0.0.0/0          

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination        
1    RH-Firewall-1-INPUT  all  --  0.0.0.0/0            0.0.0.0/0          

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination        

Chain RH-Firewall-1-INPUT (2 references)
num  target     prot opt source               destination        
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0          
2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           icmp type 255
3    ACCEPT     esp  --  0.0.0.0/0            0.0.0.0/0          
4    ACCEPT     ah   --  0.0.0.0/0            0.0.0.0/0          
5    ACCEPT     udp  --  0.0.0.0/0            224.0.0.251         udp dpt:5353
6    ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:631
7    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:631
8    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
9    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:21
10   ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22
11   REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

[root@b2ccache ~]# service iptables stop
清除防火墙规则:                                           [确定]
把 chains 设置为 ACCEPT 策略:filter                       [确定]
正在卸载 Iiptables 模块:                                  [确定]

 

redhat as4常用应用之hosts.allow和hosts.deny

http://wfbwx.blog.hexun.com/40063350_d.html

 

如何在 RedHat 中限制、允许telnet&ftp功能

Q:在 RedHat 6.x 版本中,要如何限制远端用 Telnet 或 FTP 进入 Server 主机?
A:可以在 /etc/hosts.deny & /etc/hosts.allow 加入几行设定即可。 

 

一、概述

这两个文件是tcpd服务器的配置文件,tcpd服务器可以控制外部IP对本机服务的访问。这两个配置文件的格式如下:

#服务进程名:主机列表:当规则匹配时可选的命令操作
server_name:hosts-list[:command]
/etc/hosts.allow控制可以访问本机的IP地址,/etc/hosts.deny控制禁止访问本机的IP。如果两个文件的配置有冲突,以/etc/hosts.deny为准。

/etc/hosts.allow和/etc/hosts.deny两个文件是控制远程访问设置的,通过他可以允许或者拒绝某个ip或者ip段的客户访问linux的某项服务。
比如SSH服务,我们通常只对管理员开放,那我们就可以禁用不必要的IP,而只开放管理员可能使用到的IP段。

二、配置

1、修改/etc/hosts.allow文件
#
# hosts.allow   This file describes the names of the hosts which are
#               allowed to use the local INET services, as decided
#               by the '/usr/sbin/tcpd' server.
#
sshd:210.13.218.*:allow
sshd:222.77.15.*:allow

all:218.24.129.110                #表示接受110这个ip的所有请求!

in.telnetd:140.116.44.0/255.255.255.0
in.telnetd:140.116.79.0/255.255.255.0
in.telnetd:140.116.141.99
in.telnetd:LOCAL
smbd:192.168.0.0/255.255.255.0     #允许192.168.0.网段的IP访问smbd服务

#sendmail:192.168.1.0/255.255.255.0
#pop3d:192.168.1.0/255.255.255.0
#swat:192.168.1.0/255.255.255.0
pptpd:all EXCEPT 192.168.0.0/255.255.255.0
httpd:all
vsftpd:all

以上写法表示允许210和222两个ip段连接sshd服务(这必然需要hosts.deny这个文件配合使用),当然:allow完全可以省略的。

ALL要害字匹配所有情况,EXCEPT匹配除了某些项之外的情况,PARANOID匹配你想控制的IP地址和它的域名不匹配时(域名伪装)的情况。

 

2、修改/etc/hosts.deny文件

#
# hosts.deny    This file describes the names of the hosts which are
#               *not* allowed to use the local INET services, as decided
#               by the '/usr/sbin/tcpd' server.
#
# The portmap line is redundant, but it is left to remind you that
# the new secure portmap uses hosts.deny and hosts.allow.  In particular
# you should know that NFS uses portmap!
sshd:all:deny

in.telnet:ALL

ALL:ALL EXCEPT  192.168.0.1/255.255.255.0,192.168.1.21,\
                202.10.5.0/255.255.255.0


注意看:sshd:all:deny表示拒绝了所有sshd远程连接。:deny可以省略。

3、启动服务
注意修改完后:
#service xinetd restart
才能让刚才的更改生效。

Linux hosts.allow与hosts.deny文件设置

http://purpen.iteye.com/blog/1135342

 

hosts.allow与hosts.deny
两个文件均在/etc/目录下
优先级为先检查hosts.deny,再检查hosts.allow,
后者设定可越过前者限制,

例如:
1.限制所有的ssh,
除非从218.64.87.0——127上来。
hosts.deny:
in.sshd:ALL
hosts.allow:
in.sshd:218.64.87.0/255.255.255.128

2.封掉218.64.87.0——127的telnet
hosts.deny
in.sshd:218.64.87.0/255.255.255.128

3.限制所有人的TCP连接,除非从218.64.87.0——127访问
hosts.deny
ALL:ALL
hosts.allow
ALL:218.64.87.0/255.255.255.128

4.限制218.64.87.0——127对所有服务的访问
hosts.deny
ALL:218.64.87.0/255.255.255.128

其中冒号前面是TCP daemon的服务进程名称,通常系统
进程在/etc/inetd.conf中指定,比如in.ftpd,in.telnetd,in.sshd

其中IP地址范围的写法有若干中,主要的三种是:
1.网络地址——子网掩码方式:
218.64.87.0/255.255.255.0
2.网络地址方式(我自己这样叫,呵呵)
218.64.(即以218.64打头的IP地址)
3.缩略子网掩码方式,既数一数二进制子网掩码前面有多少个“1”比如:
218.64.87.0/255.255.255.0《====》218.64.87.0/24

 

最佳的75个安全工具

http://wen66.iteye.com/blog/1457232

Tripwire 2.4.2发布,Unix数据完整性监测

http://www.iteye.com/news/17738

关于Java企业级应用开发中的安全知识的探讨

http://www.iteye.com/topic/658656

《Java加密与解密的艺术》——从写博客到写书

http://snowolf.iteye.com/category/68576

 

 

 

Tripwire是目前最为著名的unix下文件系统数据的完整性检测工具,这一软件采用的技术核心就是对每个要监控的文件产生一个数字签名,保留下来。当文件现在的数字签名与保留的数字签名不一致时,那么现在这个文件必定被改动过了,然后制定出最适合的解决方案。

 

2.4.2版本只要是添加了一些新的模板与配置集成的处理工具,并对bug的修复。

 

点击查看详情:http://freshmeat.net/projects/tripwire

 

linux常用的监控工具 <转>

http://lkf0217.iteye.com/blog/1211406

1、CACTI 工具,主要用于监控服务器网卡流量,系统硬件状态等,主要是对SNMP协议熟悉,而且会PERL与XML时候这个工具非常强大。默认就只有监控网卡流量、和一些硬盘空间的模板。还要配合RRDTOOL一起使用。


2、 NAGIOS 工具,主要用于监控服务器系统各个进程的的状态以及使用内存CPU的情况,不需要自己写脚本,就能够运行。但是不能够监控网卡流量。如果出 现情况可以给我发邮件,很及时,工具非常友好。当然也可以监控群集系统与节点。当然也可以使用插件以图形的方式查看。

3、查看apache日志工具,awstats,要比其他的工具强悍很多,也可以对轮训的日志进行查看,不需要我们手工合并日志。

4、 tripwire工具,监控文件系统是否改。缺点是只能在单机上使用,不便于在机器多的放使用(最安全的方式是把tripwire数据库刻录到光盘上,就 是再高明的黑客也不能写光盘把(指一次性写光盘))。每天运行一下,就可以知道系统的那些文件被改变过或者是修改过。aide工具是tripwire工具 的替代品,可以集中式管理。功能更加强大,但是不好配置,比较麻烦。同样也可以发邮件到指定的邮箱。

5、LINUX自带的IPTABLES,虽然是个包过滤防火墙,如果规则写好,对于抗击攻击,入侵都有一定的帮助。

6、 查看系统日志工具,logwatch和logcheck工具,这两个工具基本上做同样的事情,把最新的日志信息发送到指定的邮箱或者指定的系统用户。但是 好像有点细微的差别,就是logwatch会明确的指出那些用户登录过,系统的硬盘空间是多少以及crontab中运行的任务。logcheck只输出非 法登录的用户与与登录成功的用户,要自己仔细的去查看。这个只是我自己的观察得出的不一定准确。如:
  Oct 31 09:59:57 localhost su(pam_unix)[23330]: session opened for user root by  test(uid=500)

7、 chkrootkit 工具,是用来监测系统是否被安装了rootkit。黑客既有可能更改chkrootkit命令。最好的办法是把该命令远程备份或者是刻录到光盘里面。运行命令提示如下:
Checking `amd'... not found
Checking `basename'... not infected
Checking `biff'... not found
Checking `chfn'... not infected
Checking `chsh'... not infected
Checking `cron'... not infected
Checking `crontab'... not infected
Checking `date'... not infected
Checking `du'... not infected
Checking `dirname'... not infected
Checking `echo'... not infected
Checking `egrep'... not infected
Checking `env'... not infected
Checking `find'... not infected
Checking `fingerd'... not found
Checking `gpm'... not infected
Checking `grep'... not infected
这个说明是正常的,如果不是类似的提示,哈哈恭喜你,你赶快去买彩票把,估计500就等着你了。
8、rkhunter工具,主要检测主机内是否有木马,蠕虫等病毒。当然可检测后门程序rootkit了,同时可以发邮件给自定的邮箱。建议每天晚上跑一下还是值得的。运行该工具命令后,如果出现:
/usr/bin/find                                            [ OK ]
    /usr/bin/GET                                             [ Warning ]
    /usr/bin/groups                                          [ Warning ]
    /usr/bin/head                                            [ OK ]
    /usr/bin/id                                              [ OK ]
    /usr/bin/kill                                            [ OK ]
    /usr/bin/killall                                         [ OK ]
    /usr/bin/last                                            [ OK ]
    /usr/bin/lastlog                                         [ OK ]
    /usr/bin/ldd                                             [ Warning ]
红色的警告信息,请仔细检测是否已经中招了。我发现如果你的系统更新过他也会警告你,主要原因是与他的资料库的信息不相符,所以报警,一定要仔细查看了。
  以上工具相互配合使用才能够达到一个预期效果。是你的系统更加安全。

 

end

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics