佳木斯湛栽影视文化发展公司

主頁(yè) > 知識(shí)庫(kù) > linux服務(wù)器安全加固shell腳本代碼

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

熱門標(biāo)簽:鐵路電話系統(tǒng) 呼叫中心市場(chǎng)需求 Linux服務(wù)器 地方門戶網(wǎng)站 網(wǎng)站排名優(yōu)化 服務(wù)外包 百度競(jìng)價(jià)排名 AI電銷
復(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
您可能感興趣的文章:
  • 教你如何搭建一個(gè)安全的Linux服務(wù)器教程
  • Linux VPS安全設(shè)置之一 修改SSH端口(CentOS/Debian)
  • linux服務(wù)器基本安全配置手冊(cè)
  • Linux下Nginx安全證書ssl配置方法
  • Linux SSH 安全策略 更改 SSH 端口
  • 服務(wù)器安全狗Linux版軟件安裝使用說明
  • linux服務(wù)器下PHPCMS v9 安全配置詳解
  • Linux 服務(wù)器安全配置
  • 阿里云linux服務(wù)器上使用iptables設(shè)置安全策略的方法
  • Linux服務(wù)器下nginx的安全配置詳解
  • linux Apache服務(wù)器系統(tǒng)安全設(shè)置與優(yōu)化
  • Red Hat Linux 安全設(shè)置方法
  • centos 5.1下的安全設(shè)置(適合所有的linux版本)
  • Linux VPS安全設(shè)置之二 禁用ROOT賬戶
  • Linux SSH 安全策略 限制 IP 登錄方法
  • 安全檢測(cè)Unix和Linux服務(wù)器安全設(shè)置入門精講
  • Linux下的Apache與PHP安全設(shè)置技巧
  • Linux/CentOS服務(wù)器安全配置通用指南

標(biāo)簽:蘭州 衡水 黃山 崇左 銅川 湖南 仙桃 湘潭

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《linux服務(wù)器安全加固shell腳本代碼》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    江源县| 东平县| 阿图什市| 卢氏县| 新化县| 恩平市| 鄂伦春自治旗| 塔河县| 盐池县| 黄山市| 白水县| 和平县| 清水河县| 全州县| 耿马| 许昌市| 林州市| 山阴县| 平原县| 沙坪坝区| 康乐县| 满城县| 汽车| 靖边县| 五指山市| 城口县| 成都市| 郓城县| 兰西县| 申扎县| 德安县| 邯郸县| 红安县| 涿鹿县| 清新县| 杭锦后旗| 江津市| 阿坝县| 徐水县| 东光县| 靖江市|