美文网首页
liunx安全策略

liunx安全策略

作者: 唐古拉老山羊 | 来源:发表于2017-03-07 15:09 被阅读642次

1、修改ssh配置文件,禁止root登录,退出所有帐号,使用root登录系统

vi /etc/ssh/sshd_config

找到#PermitRootLoogin yes 改为PermitRootLoogin no

按Esc然后:wq保存退出

service sshd restart # 重启

w  #查看用户组

退出

用root 连接:显示拒绝访问

使用普通用户

ssh nita@172.16.45.126 登录成功

2

、修改配置文件,将密码最短设为8为,创建新账户,提示错误信息

vi /etc/login.defs

找到 PASS_MIN_LEN 5 改为  PASS_MIN_LEN 8

useradd yao

passwd yao

更改用户 yao 的密码 。

新的 密码:

无效的密码: 过于简单化/系统化

无效的密码: 过于简单

重新输入新的 密码:

抱歉,密码不匹配。

passwd: 已经超出服务重试的最多次数

3. 修改/etc/pam.d/ system-auth文件,确保错误登录10次,锁定此账户10分钟,将配置截图。(3分)

vi /etc/pam.d/ system-auth

#%PAM-1.0

# This file is auto-generated.

# User changes will be destroyed the next time authconfig is run.

auth        required      pam_env.so

auth        sufficient    pam_fprintd.so 后面追加以下代码:deny=10 unlock=600 even_deny_root root_unlock_time=600

4. 配置至少三个配置文件的umask值为027,将配置截图并说明是哪个配置文件。(3分)

vi /etc/bashrc 第一个文件

if [ $UID -gt 99] && [ "'id -gn'" = "'id -um'"]; then

umask 027

else

umask 027

fi

vi /etc/profile 第二个文件

追加 nmask 027

vi $HOME/bash_profile 第三个文件

unset USERNSME

namsk 027

##################################

下面几题

(如果无法执行就“ chmod +x 文件名 ”加权限)

##############################################

5. 自编脚本,查找本机存在SUID与SGID的文件,并截图。(3分)

vi 5.sh

#!/bin/bash

find / -xdev -perm -6000 -exec ls -l {} \;

查找        文件权限

vi 5_2.sh

#!/bin/bash

find / -xdev -perm +6000 -exec ls -l {} \;

6. 自编脚本,查找本机存在的所有人均有写权限的目录,并截图。(3分)

vi 6.sh

#!/bin/bash

find、-xdev -perm -0222 -type d -exec ls -ld {} \;

7. 修改配置文件,将登录超时设置为10分钟,并截图。(3分)

unset i

unset pathmounge

nmask 027

TMOUT=600

export TMOUT

8. 修改syslog.conf配置文件,将认证日志、邮件日志,备份存储到指定服务器,并截图。(3分)

syslog.conf内容

日志文件由系统日志和内核日志监控程序syslogd 与klogd 控制, 在/etc/syslog.conf 文件中配置这两个监控程序默认活动。

日志文件按/etc/syslog.conf 配置文件中的描述进行组织。以下是/etc/syslog.conf 文件的内容:

[root@localhost ~]# cat /etc/syslog.conf

# Log all kernel messages to the console.

# Logging much else clutters up the screen.

#kern.* /dev/console

# Log anything (except mail) of level info or higher.

# Don't log private authentication messages!

*.info;mail.none;authpriv.none;cron.none /var/log/messages

# The authpriv file has restricted access.

authpriv.* /var/log/secure

#在这里添加 authpriv.*  @x.x.x.x.ip地址

# Log all the mail messages in one place.

mail.* -/var/log/maillog

#在这里添加 mail.*  @x.x.x.x.ip地址

# Log cron stuff

cron.* /var/log/cron

# Everybody gets emergency messages

*.emerg *

# Save news errors of level crit and higher in a special file.

uucp,news.crit /var/log/spooler

# Save boot messages also to boot.log

local7.* /var/log/boot.log

重启syslog

service syslog restart

9. 使用root帐号登录系统,创建一个UID为0的帐号,然后使用一行命令查找本系统UID为0的帐号有哪些,并截图。(6分)

useradd -u 0 -o 帐号

cat /etc/passwd

gawk -F: '($3==0){print "NANE:"$1,"UID:"$3}' /etc/passwd

相关文章

网友评论

      本文标题:liunx安全策略

      本文链接:https://www.haomeiwen.com/subject/dqumgttx.html