Linux基線合規檢查中各文件的作用及配置腳本

1./etc/motd

操作:echo " Authorized users only. All activity may be monitored and reported " > /etc/motd

效果:telnet和ssh登錄后的輸出信息

?

2.?/etc/issue和/etc/issue.net

操作:echo " Authorized users only. All activity may be monitored and reported " > /etc/issue.net

效果:telnet主機未登錄時輸出的信息

?

3./etc/syslog.conf--遠程日志服務配置文件

?

4./etc/sysctl.conf--操作系統配置文件

?

5./etc/vsftpd/vsftpd.conf--vsftpd配置文件

?

6./etc/ssh/sshd_config--ssh配置文件

?

7./etc/hosts.allow和/etc/hosts.deny--服務連接白名單/黑名單文件

?

8./etc/pam.d/system-auth--系統登錄驗證配置文件

?

9./etc/init/control-alt-delete.conf--ctrl+alt+del快捷鍵啟用/禁用

?

10./etc/profile--環境變量配置文件,通常用于配置UMASK和TMOUT

?

11./etc/login.defs--口令(長度及有效時長等)配置文件

?

12.基線合規配置腳本(IP注意修改)

MDFDATE=`date +"%Y%m%d"`#add telnet and ssh banner
cp -p /etc/motd /etc/motd.bak${MDFDATE}
cp -p /etc/issue /etc/issue.bak${MDFDATE}
cp -p /etc/issue.net /etc/issue.net.bak${MDFDATE}
echo " Authorized users only. All activity may be monitored and reported " > /etc/motd
echo " Authorized users only. All activity may be monitored and reported " > /etc/issue
echo " Authorized users only. All activity may be monitored and reported " > /etc/issue.net
#/etc/init.d/xinetd restart#set ftp default right
cp -p /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bak${MDFDATE}
sed -i 's/#ls_recurse_enable=/ls_recurse_enable=/g' /etc/vsftpd/vsftpd.conf
echo "anon_umask=022" >> /etc/vsftpd/vsftpd.conf
#vsftpd 
sed -i '/^anonymous_enable=YES/d' /etc/vsftpd/vsftpd.conf
echo 'anonymous_enable=NO' >> /etc/vsftpd/vsftpd.conf
sed -i '/^chroot_local_user=/d' /etc/vsftpd/vsftpd.conf
echo 'chroot_local_user=YES' >> /etc/vsftpd/vsftpd.conf
sed -i '/^userlist_enable=/d' /etc/vsftpd/vsftpd.conf
echo 'userlist_enable=YES' >> /etc/vsftpd/vsftpd.conf
echo 'userlist_deny=NO' >> /etc/vsftpd/vsftpd.conf
echo 'userlist_file=/etc/vsftpd/ftpuser_deny' >> /etc/vsftpd/vsftpd.conf
cat> /etc/vsftpd/ftpuser_deny << EOF
root
daemon
bin
sys
adm
lp
uucp
nuucp
listen
nobody
noaccess
nobody4
EOF#close not need service
chkconfig cups off#forbidden icmp redirect
cp -p /etc/sysctl.conf /etc/sysctl.conf.bak${MDFDATE}
echo "net.ipv4.conf.all.accept_redirects=0" >> /etc/sysctl.conf
#sysctl -p#add remote log server
cp /etc/syslog.conf /etc/syslog.conf.bak${MDFDATE}
sed -i '/remote-host:514/a\*.info    @192.168.220.128' /etc/syslog.conf
echo 'auht.info       /var/log/authlog' >> /etc/syslog.conf
echo 'authpriv.*   /var/log/authlog' >> /etc/syslog.conf
echo '*.err;auth.info        /var/adm/messages' >> /etc/syslog.conf
touch /var/log/authlog
for f in `cat /etc/rsyslog.conf|grep -v "@"|grep -v "^#" |grep -v "^\$"|grep "/var" |grep -v "\-\/"|awk "{print$2}"`
do
chmod 640 $f
done#forbid root romote login
cp -p /etc/ssh/sshd_config /etc/ssh/sshd_config.bak${MDFDATE}
sed -i 's/^PermitRootLogin yes/#PermitRootLogin yes/g' /etc/ssh/sshd_config
sed -i '/PermitRootLogin yes/a\PermitRootLogin no' /etc/ssh/sshd_config
#/etc/init.d/sshd restart
sed -i 's/^pts/#pts/g' /etc/securetty
#ssh banner
touch /etc/sshbanner
chown bin:bin /etc/sshbanner
chmod 644 /etc/sshbanner
echo " Authorized users only. All activity may be monitored and reported "   > /etc/sshbanner
echo "Banner /etc/sshbanner" >> /etc/ssh/sshd_config
service sshd restart#limit ip to login
echo 'sshd:all:deny' >> /etc/hosts.deny
echo 'sshd:192.168.220.129:allow' >> /etc/hosts.allow
echo 'sshd:192.168.220.:allow' >> /etc/hosts.allow#add password limit
#password remember
#add auth clock
cp -p /etc/pam.d/system-auth /etc/pam.d/system-auth.bak${MDFDATE}
echo "" >> /etc/pam.d/system-auth
echo "password    requisite     pam_cracklib.so dcredit=-1 lcredit=-1 ocredit=-1 minclass=2 minlen=8" >> /etc/pam.d/system-auth
echo "password    sufficient    pam_unix.so remember=5 md5 shadow nullok try_first_pass use_authtok" >> /etc/pam.d/system-auth
echo "auth required pam_tally2.so deny=6 onerr=fail no_magic_root unlock_time=120" >> /etc/pam.d/system-auth#forbid ctrl+alt+del
cp -p /etc/inittab /etc/inittab.bak${MDFDATE}
sed -i '/ctrlaltdel/d' /etc/inittab
cp /etc/init/control-alt-delete.conf /etc/init/control-alt-delete.conf.bak${MDFDATE}
sed -i 's/^start/#start/g' /etc/init/control-alt-delete.conf
sed -i 's/^exec/#exec/g' /etc/init/control-alt-delete.conf#umask
cp -p /etc/profile /etc/profile.bak${MDFDATE}
sed -i 's/umask 022/umask 027/g' /etc/profile
echo 'umask 027' >> /etc/profile
sed -i '/^TMOUT.*/d' /etc/profile
echo "export TMOUT=540" >>/etc/profile
cp -p /etc/csh.cshrc /etc/csh.cshrc.bak${MDFDATE}
echo 'set autologout = 540' >> /etc/csh.cshrc#password file
chmod u+rw /etc/shadow
cp /etc/shadow /etc/shadow.bak${MDFDATE}
sed -i 's/^lp:/lp:!!/g' /etc/shadow
sed -i 's/^nobody:/nobody:!!/g' /etc/shadow
sed -i 's/^uucp:/uucp:!!/g' /etc/shadow
sed -i 's/^games:/games:!!/g' /etc/shadow
sed -i 's/^rpm:/rpm:!!/g' /etc/shadow
sed -i 's/^smmsp:/smmsp:!!/g' /etc/shadow
sed -i 's/^nfsnobody:/nfsnobody:!!/g' /etc/shadow
chmod 0644 /etc/passwd
chmod 0400 /etc/shadow
chmod 0644 /etc/groupcp /etc/login.defs /etc/login.defs.bak${MDFDATE}
sed -i 's/PASS_MIN_LEN.*5*/PASS_MIN_LEN    8/g'  /etc/login.defs
sed -i 's/PASS_MAX_DAYS.*99999/PASS_MAX_DAYS   90/g' /etc/login.defs#application user
#useradd -U forchk
View Code

?

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/391714.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/391714.shtml
英文地址,請注明出處:http://en.pswp.cn/news/391714.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

tableau使用_使用Tableau升級Kaplan-Meier曲線

tableau使用In a previous article, I showed how we can create the Kaplan-Meier curves using Python. As much as I love Python and writing code, there might be some alternative approaches with their unique set of benefits. Enter Tableau!在上一篇文章中 &#x…

踩坑 net core

webclient 可以替換為 HttpClient 下載獲取url的內容&#xff1a; 證書&#xff1a; https://stackoverflow.com/questions/40014047/add-client-certificate-to-net-core-httpclient 轉載于:https://www.cnblogs.com/zxs-onestar/p/7340386.html

我從參加#PerfMatters會議中學到的東西

by Stacey Tay通過史黛西泰 我從參加#PerfMatters會議中學到的東西 (What I learned from attending the #PerfMatters conference) 從前端的網絡運行情況發布會上的注意事項 (Notes from a front-end web performance conference) This week I had the privilege of attendin…

修改innodb_flush_log_at_trx_commit參數提升insert性能

最近&#xff0c;在一個系統的慢查詢日志里發現有個insert操作很慢&#xff0c;達到秒級&#xff0c;并且是比較簡單的SQL語句&#xff0c;把語句拿出來到mysql中直接執行&#xff0c;速度卻很快。 這種問題一般不是SQL語句本身的問題&#xff0c;而是在具體的應用環境中&#…

leetcode 1178. 猜字謎(位運算)

外國友人仿照中國字謎設計了一個英文版猜字謎小游戲&#xff0c;請你來猜猜看吧。 字謎的迷面 puzzle 按字符串形式給出&#xff0c;如果一個單詞 word 符合下面兩個條件&#xff0c;那么它就可以算作謎底&#xff1a; 單詞 word 中包含謎面 puzzle 的第一個字母。 單詞 word…

Nexus3.x.x上傳第三方jar

exus3.x.x上傳第三方jar&#xff1a; 1. create repository 選擇maven2(hosted)&#xff0c;說明&#xff1a; proxy&#xff1a;即你可以設置代理&#xff0c;設置了代理之后&#xff0c;在你的nexus中找不到的依賴就會去配置的代理的地址中找hosted&#xff1a;你可以上傳你自…

責備的近義詞_考試結果危機:我們應該責備算法嗎?

責備的近義詞I’ve been considering writing on the topic of algorithms for a little while, but with the Exam Results Fiasco dominating the headline news in the UK during the past week, I felt that now is the time to look more closely into the subject.我一直…

電腦如何設置終端設置代理_如何設置一個嚴肅的Kubernetes終端

電腦如何設置終端設置代理by Chris Cooney克里斯庫尼(Chris Cooney) 如何設置一個嚴肅的Kubernetes終端 (How to set up a serious Kubernetes terminal) 所有k8s書呆子需要的CLI工具 (All the CLI tools a growing k8s nerd needs) Kubernetes comes pre-packaged with an ou…

spring cloud(二)

1. Feign應用 Feign的作用&#xff1b;使用Feign實現consumer-demo代碼中調用服務 導入啟動器依賴&#xff1b;開啟Feign功能&#xff1b;編寫Feign客戶端&#xff1b;編寫一個處理器ConsumerFeignController&#xff0c;注入Feign客戶端并使用&#xff1b;測試 <dependen…

c/c++編譯器的安裝

MinGW(Minimalist GNU For Windows)是個精簡的Windows平臺C/C、ADA及Fortran編譯器&#xff0c;相比Cygwin而言&#xff0c;體積要小很多&#xff0c;使用較為方便。 MinGW最大的特點就是編譯出來的可執行文件能夠獨立在Windows上運行。 MinGW的組成&#xff1a; 編譯器(支持C、…

滲透工具

滲透工具 https://blog.csdn.net/Fly_hps/article/details/89306104 查詢工具 https://blog.csdn.net/Fly_hps/article/details/89070552 轉載于:https://www.cnblogs.com/liuYGoo/p/11347693.html

numpy 線性代數_數據科學家的線性代數—用NumPy解釋

numpy 線性代數Machine learning and deep learning models are data-hungry. The performance of them is highly dependent on the amount of data. Thus, we tend to collect as much data as possible in order to build a robust and accurate model. Data is collected i…

spring 注解方式配置Bean

概要&#xff1a; 再classpath中掃描組件 組件掃描&#xff08;component scanning&#xff09;&#xff1a;Spring可以從classpath下自己主動掃描。偵測和實例化具有特定注解的組件特定組件包含&#xff1a; Component&#xff1a;基本注解。標示了一個受Spring管理的組件&…

主成分分析 獨立成分分析_主成分分析概述

主成分分析 獨立成分分析by Moshe Binieli由Moshe Binieli 主成分分析概述 (An overview of Principal Component Analysis) This article will explain you what Principal Component Analysis (PCA) is, why we need it and how we use it. I will try to make it as simple…

擴展方法略好于幫助方法

如果針對一個類型實例的代碼片段經常被用到&#xff0c;我們可能會想到把之封裝成幫助方法。如下是一段針對DateTime類型實例的一段代碼&#xff1a;class Program{static void Main(string[] args){DateTime d new DateTime(2001,5,18);switch (d.DayOfWeek){case DayOfWeek.…

零元學Expression Blend 4 - Chapter 25 以Text相關功能就能簡單做出具有設計感的登入畫面...

原文:零元學Expression Blend 4 - Chapter 25 以Text相關功能就能簡單做出具有設計感的登入畫面本章將交大家如何運用Blend 4 內的Text相關功能做出有設計感的登入畫面 讓你五分鐘就能快速做出一個登入畫面 ? 本章將教大家如何運用Blend 4 內的Text相關功能做出有設計感的登入…

leetcode 395. 至少有 K 個重復字符的最長子串(滑動窗口)

給你一個字符串 s 和一個整數 k &#xff0c;請你找出 s 中的最長子串&#xff0c; 要求該子串中的每一字符出現次數都不少于 k 。返回這一子串的長度。 示例 1&#xff1a; 輸入&#xff1a;s “aaabb”, k 3 輸出&#xff1a;3 解釋&#xff1a;最長子串為 “aaa” &…

冠狀病毒時代的負責任數據可視化

First, a little bit about me: I’m a data science grad student. I have been writing for Medium for a little while now. I’m a scorpio. I like long walks on beaches. And writing for Medium made me realize the importance of taking personal responsibility ove…

集合_java集合框架

轉載自http://blog.csdn.net/zsw101259/article/details/7570033 Java集合框架圖 簡化圖&#xff1a; Java平臺提供了一個全新的集合框架。“集合框架”主要由一組用來操作對象的接口組成。不同接口描述一組不同數據類型。 1、Java 2集合框架圖 ①集合接口&#xff1a;6個…

顯示隨機鍵盤

顯示隨機鍵盤 1 <!DOCTYPE html>2 <html lang"zh-cn">3 <head>4 <meta charset"utf-8">5 <title>7-77 課堂演示</title>6 <link rel"stylesheet" type"text/css" href"style…