欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

linux服務(wù)器安全加固shell腳本代碼

 更新時(shí)間:2013年06月11日 15:05:34   作者:  
有時(shí)候安裝完服務(wù)器以后,需要一些安全設(shè)置,這段腳本就是為了安全加固所寫(xiě),需要的朋友可以參考下
復(fù)制代碼 代碼如下:

#!/bin/sh
# desc: setup linux system security
# author:coralzd
# powered by www.freebsdsystem.org
# version 0.1.2 written by 2011.05.03
#account setup

passwd -l xfs
passwd -l news
passwd -l nscd
passwd -l dbus
passwd -l vcsa
passwd -l games
passwd -l nobody
passwd -l avahi
passwd -l haldaemon
passwd -l gopher
passwd -l ftp
passwd -l mailnull
passwd -l pcap
passwd -l mail
passwd -l shutdown
passwd -l halt
passwd -l uucp
passwd -l operator
passwd -l sync
passwd -l adm
passwd -l lp

# chattr /etc/passwd /etc/shadow
chattr +i /etc/passwd
chattr +i /etc/shadow
chattr +i /etc/group
chattr +i /etc/gshadow
# add continue input failure 3 ,passwd unlock time 5 minite
sed -i 's#auth        required      pam_env.so#auth        required      pam_env.so\nauth       required       pam_tally.so  onerr=fail deny=3 unlock_time=300\nauth           required     /lib/security/$ISA/pam_tally.so onerr=fail deny=3 unlock_time=300#' /etc/pam.d/system-auth
# system timeout 5 minite auto logout
echo "TMOUT=300" >>/etc/profile

# will system save history command list to 10
sed -i "s/HISTSIZE=1000/HISTSIZE=10/" /etc/profile

# enable /etc/profile go!
source /etc/profile

# add syncookie enable /etc/sysctl.conf
echo "net.ipv4.tcp_syncookies=1" >> /etc/sysctl.conf

sysctl -p # exec sysctl.conf enable
# optimizer sshd_config

sed -i "s/#MaxAuthTries 6/MaxAuthTries 6/" /etc/ssh/sshd_config
sed -i  "s/#UseDNS yes/UseDNS no/" /etc/ssh/sshd_config

# limit chmod important commands
chmod 700 /bin/ping
chmod 700 /usr/bin/finger
chmod 700 /usr/bin/who
chmod 700 /usr/bin/w
chmod 700 /usr/bin/locate
chmod 700 /usr/bin/whereis
chmod 700 /sbin/ifconfig
chmod 700 /usr/bin/pico
chmod 700 /bin/vi
chmod 700 /usr/bin/which
chmod 700 /usr/bin/gcc
chmod 700 /usr/bin/make
chmod 700 /bin/rpm

# history security

chattr +a /root/.bash_history
chattr +i /root/.bash_history

# write important command md5
cat > list << "EOF" &&
/bin/ping
/bin/finger
/usr/bin/who
/usr/bin/w
/usr/bin/locate
/usr/bin/whereis
/sbin/ifconfig
/bin/pico
/bin/vi
/usr/bin/vim
/usr/bin/which
/usr/bin/gcc
/usr/bin/make
/bin/rpm
EOF

for i in `cat list`
do
   if [ ! -x $i ];then
   echo "$i not found,no md5sum!"
  else
   md5sum $i >> /var/log/`hostname`.log
  fi
done
rm -f list

相關(guān)文章

  • Linux中修改文件名的多種方法總結(jié)

    Linux中修改文件名的多種方法總結(jié)

    在Linux系統(tǒng)中,通過(guò)命令行界面可以方便地修改文件名,本篇博客將介紹幾種常見(jiàn)的方法,包括mv命令、rename命令、find和mv命令的組合、sed命令以及使用bash腳本,這些方法可以根據(jù)實(shí)際需求進(jìn)行選擇,提供了靈活性和多樣性,需要的朋友可以參考下
    2024-01-01
  • Linux oracle數(shù)據(jù)庫(kù)自動(dòng)備份自動(dòng)壓縮腳本代碼

    Linux oracle數(shù)據(jù)庫(kù)自動(dòng)備份自動(dòng)壓縮腳本代碼

    這篇文章主要介紹了Linux oracle數(shù)據(jù)庫(kù)備份完成后可以自動(dòng)壓縮腳本代碼,大家參考使用
    2013-12-12
  • journalctl 命令使用小結(jié)

    journalctl 命令使用小結(jié)

    journalctl命令是Linux系統(tǒng)中一個(gè)用于查詢和管理系統(tǒng)日志的命令行工具,它基于systemd的日志守護(hù)進(jìn)程systemd-journald的功能,這篇文章主要介紹了journalctl 命令使用總結(jié),需要的朋友可以參考下
    2024-06-06
  • linux rsync安裝 配置 實(shí)例詳解

    linux rsync安裝 配置 實(shí)例詳解

    這篇文章主要介紹了linux rsync安裝 配置 實(shí)例詳解,需要的朋友可以參考下
    2015-11-11
  • 淺談shell數(shù)組的定義及循環(huán)

    淺談shell數(shù)組的定義及循環(huán)

    今天小編就為大家分享一篇淺談shell數(shù)組的定義及循環(huán),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-06-06
  • bash判斷文件或文件夾是否存在的shell代碼

    bash判斷文件或文件夾是否存在的shell代碼

    這篇文章主要介紹了bash判斷文件或文件夾是否存在的shell代碼,需要的朋友可以參考下
    2017-05-05
  • shell讀取配置文件的方式sed命令詳解

    shell讀取配置文件的方式sed命令詳解

    在編寫(xiě)啟動(dòng)腳本時(shí),涉及到讀取配置文件,特地記錄下shell腳本讀取啟動(dòng)文件的方式,這篇文章主要介紹了shell讀取配置文件-sed命令,需要的朋友可以參考下
    2023-04-04
  • Shell常見(jiàn)用法小記

    Shell常見(jiàn)用法小記

    本文簡(jiǎn)要介紹了下shell入門(mén)的一些用法,具有很好的參考價(jià)值。下面跟著小編一起來(lái)看下吧
    2017-04-04
  • Shell腳本查看進(jìn)程內(nèi)存真實(shí)占用情況

    Shell腳本查看進(jìn)程內(nèi)存真實(shí)占用情況

    這篇文章主要介紹了Shell腳本查看進(jìn)程內(nèi)存真實(shí)占用情況,本文直接給出實(shí)現(xiàn)代碼,需要的朋友可以參考下
    2014-12-12
  • shell命令行參數(shù)用法簡(jiǎn)介

    shell命令行參數(shù)用法簡(jiǎn)介

    本文介紹了shell命令行參數(shù)的用法,對(duì)于普通腳本語(yǔ)言諸如perl python等,寫(xiě)一個(gè)腳本程序,包裝命令行參數(shù)時(shí),一般都是用getopt之類(lèi)的;c語(yǔ)言也類(lèi)似
    2014-04-04

最新評(píng)論