Linux的系統安全設定Shell指令碼

來源:互聯網
上載者:User

標籤:

#!/bin/sh# desc: setup linux system security# powered by www.lvtao.net#account setuppasswd -l xfspasswd -l newspasswd -l nscdpasswd -l dbuspasswd -l vcsapasswd -l gamespasswd -l nobodypasswd -l avahipasswd -l haldaemonpasswd -l gopherpasswd -l ftppasswd -l mailnullpasswd -l pcappasswd -l mailpasswd -l shutdownpasswd -l haltpasswd -l uucppasswd -l operatorpasswd -l syncpasswd -l admpasswd -l lp# chattr /etc/passwd /etc/shadowchattr +i /etc/passwdchattr +i /etc/shadowchattr +i /etc/groupchattr +i /etc/gshadow# add continue input failure 3 ,passwd unlock time 5 minitesed -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 logoutecho "TMOUT=300" >>/etc/profile# will system save history command list to 10sed -i "s/HISTSIZE=1000/HISTSIZE=10/" /etc/profile# enable /etc/profile go!source /etc/profile# add syncookie enable /etc/sysctl.confecho "net.ipv4.tcp_syncookies=1" >> /etc/sysctl.confsysctl -p # exec sysctl.conf enable# optimizer sshd_configsed -i "s/#MaxAuthTries 6/MaxAuthTries 6/" /etc/ssh/sshd_configsed -i "s/#UseDNS yes/UseDNS no/" /etc/ssh/sshd_config# limit chmod important commandschmod 700 /bin/pingchmod 700 /usr/bin/fingerchmod 700 /usr/bin/whochmod 700 /usr/bin/wchmod 700 /usr/bin/locatechmod 700 /usr/bin/whereischmod 700 /sbin/ifconfigchmod 700 /usr/bin/picochmod 700 /bin/vichmod 700 /usr/bin/whichchmod 700 /usr/bin/gccchmod 700 /usr/bin/makechmod 700 /bin/rpm# history securitychattr +a /root/.bash_historychattr +i /root/.bash_history# write important command md5cat > 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`.logfidonerm -f list

執行sh security.sh

Linux的系統安全設定Shell指令碼

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.