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

主頁(yè) > 知識(shí)庫(kù) > 一個(gè)Linux系統(tǒng)安全設(shè)置的Shell腳本的分享(適用CentOS)

一個(gè)Linux系統(tǒng)安全設(shè)置的Shell腳本的分享(適用CentOS)

熱門(mén)標(biāo)簽:呼叫中心市場(chǎng)需求 AI電銷(xiāo) 服務(wù)外包 地方門(mén)戶網(wǎng)站 鐵路電話系統(tǒng) Linux服務(wù)器 百度競(jìng)價(jià)排名 網(wǎng)站排名優(yōu)化

我們將常用的系統(tǒng)安全配置制作為一個(gè)shell腳本,只需要在服務(wù)器上運(yùn)行這個(gè)shell腳本即可完成安全設(shè)置。

linux的系統(tǒng)安全設(shè) 置Shell腳本是第二次更新,已經(jīng)大量應(yīng)用在某大型媒體網(wǎng)站體系中,加入了之前沒(méi)有想到的一些安全設(shè)置。使用方法將其復(fù)制,保存為一個(gè)shell文件, 比如security.sh.將其上傳到Linux服務(wù)器上,執(zhí)行sh security.sh,就可以使用該腳本了!

復(fù)制代碼 代碼如下:
#!/bin/sh
# desc: setup linux system security
#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.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
# 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

您可能感興趣的文章:
  • 一鍵配置CentOS iptables防火墻的Shell腳本分享
  • Centos下IP與DNS設(shè)置方法詳解
  • CentOS Linux服務(wù)器安全設(shè)置
  • CentOS6.5設(shè)置Django開(kāi)發(fā)環(huán)境
  • Centos 6.5 服務(wù)器優(yōu)化配置備忘(一些基礎(chǔ)優(yōu)化和安全設(shè)置)
  • centos最小化安裝系統(tǒng)后的基本調(diào)優(yōu)及安全設(shè)置
  • centos 5.1下的安全設(shè)置(適合所有的linux版本)
  • CentOS的圖形安裝及初始環(huán)境設(shè)置教程
  • CentOS防火墻用法淺析

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

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《一個(gè)Linux系統(tǒng)安全設(shè)置的Shell腳本的分享(適用CentOS)》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wè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
    沭阳县| 宜君县| 平湖市| 临颍县| 辰溪县| 梁平县| 怀化市| 秦安县| 金川县| 双鸭山市| 萝北县| 同仁县| 中牟县| 砚山县| 合肥市| 镇巴县| 顺义区| 乃东县| 西丰县| 咸宁市| 南部县| 凤庆县| 洮南市| 油尖旺区| 济阳县| 东至县| 湛江市| 衡阳县| 如东县| 平顶山市| 马关县| 闸北区| 桑日县| 泌阳县| 宁蒗| 望城县| 房产| 宜都市| 中宁县| 商都县| 垫江县|