1
- #! /bin/sh
2
-
3
- passwd -l xfs
4
- passwd -l news
5
- passwd -l nscd
6
- passwd -l dbus
7
- passwd -l vcsa
8
- passwd -l games
9
- passwd -l nobody
10
- passwd -l avahi
11
- passwd -l haldaemon
12
- passwd -l gopher
13
- passwd -l ftp
14
- passwd -l mailnull
15
- passwd -l pcap
16
- passwd -l mail
17
- passwd -l shutdown
18
- passwd -l halt
19
- passwd -l uucp
20
- passwd -l operator
21
- passwd -l sync
22
- passwd -l adm
23
- passwd -l lp
24
-
25
- # chattr /etc/passwd /etc/shadow
26
- chattr +i /etc/passwd
27
- chattr +i /etc/shadow
28
- chattr +i /etc/group
29
- chattr +i /etc/gshadow
30
-
31
- # add continue input failure 3 ,passwd unlock time 5 minite
32
- sed -i ' s#auth required pam_env.so#auth required pam_env.sonauth required pam_tally.so onerr=fail deny=3 unlock_time=300nauth required /lib/security/$ISA/pam_tally.so onerr=fail deny=3 unlock_time=300#' /etc/pam.d/system-auth
33
- # system timeout 5 minite auto logout
34
- echo " TMOUT=300" >> /etc/profile
35
-
36
- # will system save history command list to 10
37
- sed -i " s/HISTSIZE=1000/HISTSIZE=10/" /etc/profile
38
-
39
- # enable /etc/profile go!
40
- source /etc/profile
41
-
42
- # add syncookie enable /etc/sysctl.conf
43
- echo " net.ipv4.tcp_syncookies=1" >> /etc/sysctl.conf
44
-
45
- sysctl -p # exec sysctl.conf enable
46
- # optimizer sshd_config
47
-
48
- sed -i " s/#MaxAuthTries 6/MaxAuthTries 6/" /etc/ssh/sshd_config
49
- sed -i " s/#UseDNS yes/UseDNS no/" /etc/ssh/sshd_config
50
-
51
- # limit chmod important commands
52
- chmod 700 /bin/ping
53
- chmod 700 /usr/bin/finger
54
- chmod 700 /usr/bin/who
55
- chmod 700 /usr/bin/w
56
- chmod 700 /usr/bin/locate
57
- chmod 700 /usr/bin/whereis
58
- chmod 700 /sbin/ifconfig
59
- chmod 700 /usr/bin/pico
60
- chmod 700 /bin/vi
61
- chmod 700 /usr/bin/which
62
- chmod 700 /usr/bin/gcc
63
- chmod 700 /usr/bin/make
64
- chmod 700 /bin/rpm
65
-
66
- # history security
67
-
68
- chattr +a /root/.bash_history
69
- chattr +i /root/.bash_history
70
-
71
- # write important command md5
72
- cat > list << "EOF " &&
73
- /bin/ping
74
- /bin/finger
75
- /usr/bin/who
76
- /usr/bin/w
77
- /usr/bin/locate
78
- /usr/bin/whereis
79
- /sbin/ifconfig
80
- /bin/pico
81
- /bin/vi
82
- /usr/bin/vim
83
- /usr/bin/which
84
- /usr/bin/gcc
85
- /usr/bin/make
86
- /bin/rpm
87
- EOF
88
-
89
- for i in ` cat list`
90
- do
91
- if [ ! -x $i ]; then
92
- echo " $i not found,no md5sum!"
93
- else
94
- md5sum $i >> /var/log/` hostname` .log
95
- fi
96
- done
1
+ #! /bin/sh
2
+
3
+ passwd -l xfs
4
+ passwd -l news
5
+ passwd -l nscd
6
+ passwd -l dbus
7
+ passwd -l vcsa
8
+ passwd -l games
9
+ passwd -l nobody
10
+ passwd -l avahi
11
+ passwd -l haldaemon
12
+ passwd -l gopher
13
+ passwd -l ftp
14
+ passwd -l mailnull
15
+ passwd -l pcap
16
+ passwd -l mail
17
+ passwd -l shutdown
18
+ passwd -l halt
19
+ passwd -l uucp
20
+ passwd -l operator
21
+ passwd -l sync
22
+ passwd -l adm
23
+ passwd -l lp
24
+
25
+ # chattr /etc/passwd /etc/shadow
26
+ chattr +i /etc/passwd
27
+ chattr +i /etc/shadow
28
+ chattr +i /etc/group
29
+ chattr +i /etc/gshadow
30
+
31
+ # add continue input failure 3 ,passwd unlock time 5 minite
32
+ sed -i ' s#auth required pam_env.so#auth required pam_env.sonauth required pam_tally.so onerr=fail deny=3 unlock_time=300nauth required /lib/security/$ISA/pam_tally.so onerr=fail deny=3 unlock_time=300#' /etc/pam.d/system-auth
33
+ # system timeout 5 minite auto logout
34
+ echo " TMOUT=300" >> /etc/profile
35
+
36
+ # will system save history command list to 10
37
+ sed -i " s/HISTSIZE=1000/HISTSIZE=10/" /etc/profile
38
+
39
+ # enable /etc/profile go!
40
+ source /etc/profile
41
+
42
+ # add syncookie enable /etc/sysctl.conf
43
+ echo " net.ipv4.tcp_syncookies=1" >> /etc/sysctl.conf
44
+
45
+ sysctl -p # exec sysctl.conf enable
46
+ # optimizer sshd_config
47
+
48
+ sed -i " s/#MaxAuthTries 6/MaxAuthTries 6/" /etc/ssh/sshd_config
49
+ sed -i " s/#UseDNS yes/UseDNS no/" /etc/ssh/sshd_config
50
+
51
+ # limit chmod important commands
52
+ chmod 700 /bin/ping
53
+ chmod 700 /usr/bin/finger
54
+ chmod 700 /usr/bin/who
55
+ chmod 700 /usr/bin/w
56
+ chmod 700 /usr/bin/locate
57
+ chmod 700 /usr/bin/whereis
58
+ chmod 700 /sbin/ifconfig
59
+ chmod 700 /usr/bin/pico
60
+ chmod 700 /bin/vi
61
+ chmod 700 /usr/bin/which
62
+ chmod 700 /usr/bin/gcc
63
+ chmod 700 /usr/bin/make
64
+ chmod 700 /bin/rpm
65
+
66
+ # history security
67
+
68
+ chattr +a /root/.bash_history
69
+ chattr +i /root/.bash_history
70
+
71
+ # write important command md5
72
+ cat > list << "EOF " &&
73
+ /bin/ping
74
+ /bin/finger
75
+ /usr/bin/who
76
+ /usr/bin/w
77
+ /usr/bin/locate
78
+ /usr/bin/whereis
79
+ /sbin/ifconfig
80
+ /bin/pico
81
+ /bin/vi
82
+ /usr/bin/vim
83
+ /usr/bin/which
84
+ /usr/bin/gcc
85
+ /usr/bin/make
86
+ /bin/rpm
87
+ EOF
88
+
89
+ for i in ` cat list`
90
+ do
91
+ if [ ! -x $i ]; then
92
+ echo " $i not found,no md5sum!"
93
+ else
94
+ md5sum $i >> /var/log/` hostname` .log
95
+ fi
96
+ done
97
97
rm -f list
0 commit comments