Linux 服务器安全运维

来源:互联网 发布:淘宝会员名叫什么好呢 编辑:程序博客网 时间:2024/06/07 19:52

Linux 服务器安全运维

1.1

删除多余的用户和组

可删除的用户:adm,lp,sync,shutdown,halt,news,uucp,operator,games,gopher
可删除的组:adm,lp,news,uucp,games,dip,pppusers,popusers,slipusers
eg:
userdel games
groupdel games

禁用用户的登录功能

usermod -s /sbin/nologin user1

关闭不必要的服务

chkconfig –level 345 bluetooth off

ubuntu下是 update-rc.d

密码安全策略 ssh

修改配置 启用PublicKey认证,禁用密码认证

Protocol 2
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no

su, sudo

允许sudo权限
user0 ALL=/bin/more /etc/shadow

允许sudo执行固定命令免密码
user0 ALL= NOPASSWD:/bin/more /etc/shadow

sudo免密码放行所有命令
user0 ALL=(ALL)NOPASSWD:ALL

1.2

备份shell历史日志

通过tcp_wrappers限制访问

Linux系统服务是否可以使用tcp_warppers防火墙取决于服务是否应用了libwrapped库文件
/etc/hosts.allow /etc/hosts.deny
server:host(s) [:action]
eg:
ALL:ALL EXCEPT 192.168.1.2

eg2:
在hosts.deny中添加
sshd:ALL
禁止所有其他用户产生ssh连接

1.3

chattr lsattr

# chattr -hUsage: chattr [-RVf] [-+=AaCcDdeijsSu] [-v version] files...a 只可以添加数据i 文件不能被修改Usage: lsattr [-RVadlv] [files...]

文件权限的检查和修改

find --helpUsage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]find   path   -option   [   -print ]   [ -exec   -ok   command ]   {} \;-name   filename             #查找名为filename的文件-type    b/d/c/p/l/f         #查是块设备、目录、字符设备、管道、符号链接、普通文件-perm                        #按执行权限来查找-user    username             #按文件属主来查找-prune                       #忽略某个目录-newer   f1 !f2               #查更改时间比f1新但比f2旧的文件-print: find命令将匹配的文件输出到标准输出。-exec: find命令对匹配的文件执行该参数所给出的shell命令。相应命令的形式为'command' { } \;,注意{ }和\;之间的空格。-ok: 和-exec的作用相同,只不过以一种更为安全的模式来执行该参数所给出的shell命令,在执行每一个命令之前,都会给出提示,让用户来确定是否执行。

/tmp /var/tmp /dev/shm 安全设定

0 0