Linux安全加固腳本的示例分析-創(chuàng)新互聯(lián)

今天就跟大家聊聊有關(guān)Linux安全加固腳本的示例分析,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。

成都創(chuàng)新互聯(lián)公司堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站建設(shè)、做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時代的普洱網(wǎng)站設(shè)計(jì)、移動媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
#安全加固腳本
#!/bin/bash
 
#version1.0;write at 2017-03-29;
#write by Ringoo;
 
#1.將root管理員名稱修改為Ringoo
useradd -u 0 -g 0 -o ringoo
useradd pso
 
#2.修改默認(rèn)密碼策略
#備份文件
cp /etc/login.defs   /etc/login.defs.bak
sed -i 's/99999/90/' /etc/login.defs
 
#3.設(shè)置3次輸錯密碼鎖定用戶
#備份文件
cp /etc/pam.d/system-auth /etc/pam.d/system-auth.bak
sed -e '5 i\auth        required      /lib64/security/pam_tally2.so deny=3 unlock_time=300' -i /etc/pam.d/system-auth
#密碼復(fù)雜度設(shè)置
sed -e "14 i\password    requisite     pam_cracklib.so minlen=10 difok=3 lcredit=-1 ucredit=-1 dcredit=-1 ocredit=-1 try_first_pass retry=3" -i /etc/pam.d/system-auth
sed -e '15d'  -i /etc/pam.d/system-auth
 
#修改/etc/profile
#備份文件
cp /etc/profile /etc/profile.bak
sed -e 's/HISTSIZE=1000/HISTSIZE=3000/' -i /etc/profile
sed -i "/HISTSIZE=3000/a HISTTIMEFORMAT=\"%F %T \"" /etc/profile
sed -i "/HISTSIZE=3000/a TMOUT=1800" /etc/profile
sed -i "$ a\export HISTORY_FILE=/var/log/useraudit.log" /etc/profile
sed -i "$ a\export PROMPT_COMMAND=\'{ h=\`history 1\`;w=\`who am i\`;echo -e \$(date \"+%Y-%m-%d %H:%M:%S\") --- \$w ---\$h;} >> \$HISTORY_FILE\'" /etc/profile
 
/bin/touch /var/log/useraudit.log
/bin/chmod 777 /var/log/useraudit.log
/usr/bin/chattr +a /var/log/useraudit.log
 
#修改sshd配置
#備份文件
cp /etc/ssh/sshd_config   /etc/ssh/sshd_config.bak
sed -e 's/\#PermitRootLogin yes/PermitRootLogin no/' -i /etc/ssh/sshd_config
sed -e 's/\#Port 22/Port 2222/' -i /etc/ssh/sshd_config
sed -e 's/\#UseDNS yes/UseDNS no/' -i /etc/ssh/sshd_config
sed -e 's/X11Forwarding yes/X11Forwarding no/' -i /etc/ssh/sshd_config
sed -e 's/GSSAPIAuthentication yes/\#GSSAPIAuthentication yes/' -i /etc/ssh/sshd_config
sed -e 's/GSSAPICleanupCredentials yes/\#GSSAPICleanupCredentials yes/' -i /etc/ssh/sshd_config
#/etc/init.d/sshd restart
 
#禁用不需要的服務(wù)
/sbin/chkconfig ip6tables off
/sbin/chkconfig iptables off
/sbin/chkconfig avahi-daemon off
/sbin/chkconfig avahi-dnsconfd off
 
#數(shù)據(jù)庫服務(wù)器這里請酌情配置
#備份文件
#cp /etc/pam.d/login /etc/pam.d/login.bak
#cp /etc/security/limits.conf  /etc/security/limits.conf.bak
#sed -i "$ a\session    required     /lib64/security/pam_limits.so" /etc/pam.d/login
#sed -i "$ a\*  soft  nofile          65535" /etc/security/limits.conf
#sed -i "$ a\*  hard  nofile          65535" /etc/security/limits.conf
 
echo "please restart the server for the settings to take effect,press enter exit" 
read pause
exit 1

看完上述內(nèi)容,你們對Linux安全加固腳本的示例分析有進(jìn)一步的了解嗎?如果還想了解更多知識或者相關(guān)內(nèi)容,請關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司行業(yè)資訊頻道,感謝大家的支持。

分享文章:Linux安全加固腳本的示例分析-創(chuàng)新互聯(lián)
分享地址:http://muchs.cn/article28/ddhicp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供響應(yīng)式網(wǎng)站、用戶體驗(yàn)網(wǎng)站排名、網(wǎng)站內(nèi)鏈、虛擬主機(jī)、自適應(yīng)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站優(yōu)化排名