LINUX安全設定

2022-04-02 02:22:44 字數 2467 閱讀 2464

3、 為單使用者引導加上密碼

在「/etc/lilo.conf」檔案中加入三個引數:time-out,restricted,password。這三個引數可以使你的系統在啟動lilo時就要求密碼驗證。 

boot=/dev/hda 

map=/boot/map 

install=/boot/boot.b 

time-out=00 #把這行該為00 

prompt 

default=linux 

##########加入這行 

restricted 

##########加入這行並設定自己的密碼 

password= 

image=/boot/vmlinuz-2.2.14-12 

label=linux 

initrd=/boot/initrd-2.2.14-12.img 

root=/dev/hda6 

read-only 

b):因為"/etc/lilo.conf"檔案中包含明文密碼,所以要把它設定為root許可權讀取。 

[root]# chmod 600 /etc/lilo.conf 

c):更新系統,以便對「/etc/lilo.conf」檔案做的修改起作用。 

[root]# /sbin/lilo -v 

d):使用「chattr」命令使"/etc/lilo.conf"檔案變為不可改變。 

[root]# chattr +i /etc/lilo.conf 

4、禁止control-alt-delete 鍵盤關閉命令 

在"/etc/inittab" 檔案中注釋掉下面這行: 

#ca::ctrlaltdel:/sbin/shutdown -t3 -r now 

為了使這項改動起作用,輸入下面這個命令: 

[root]# /sbin/init q

二、隱藏系統的資訊 

1、在預設的情況下,當登陸到linux系統上,系統回列印出linux系統的版本,名稱核心服務等資訊。所以我們需要修改讓他只顯示乙個login:登陸符號

#this will overwrite /etc/issue at every boot.so,make any changes you 

#want to make to /etc/issue here or you will lose them when you reboot. 

#echo "">/etc/issue 

#echo "$r">>/etc/issue 

#echo "kernel $(uname -r) on $a $(uname -m)">>/etc/issue 

# #cp -f /etc/issue/etc/issue.net 

#echo >> /etc/issue 

(2):刪除/etc目錄下的issue.net和issue檔案。 

[boot]#rm -f /etc/issue 

[boot]#rm -f /etc/issue.net 

[root]# touch /etc/issue 

[root]# touch /etc/issue 

2、當有人遠端登陸時,禁止顯示系統歡迎資訊。你可以通過修改「/etc/inetd.conf」檔案來達到這個目的。 

把/etc/inetd.conf檔案下面這行: 

telnet stream tcp nowait root /usr/sbin/tcpd in.telnetd 

修改為: 

telnet stream tcp nowait root /usr/sbin/tcpd in.telnetd -h 

在最後加「-h」可以使當有人登陸時只顯示乙個login:提示,而不顯示系統歡迎資訊。 

3、歷史命令 

bash shell在「~/.bash_history」(「~/」表示使用者目錄)檔案中儲存了500條使用過的命令,這樣可以使你輸入使用過的長命令變得容易。每個在系統中擁有賬號的使用者在他的目錄下都有乙個「.bash_history」檔案。

bash shell應該儲存少量的命令,並且在每次使用者登出時都把這些歷史命令刪除。 

(1)「/etc/profile」檔案中的「histfilesize」和「histsize」行確定所有使用者的「.bash_history」檔案中可以儲存的舊命令條數。把「/etc/profile」檔案中的「histfilesize」和「histsize」行的值設為乙個較小的數。編輯profile檔案(vi /etc/profile),把下面這行改為:

histfilesize=30 //設為30 

histsize=30 //不要把histsize置零,那樣就不能使用上下健來呼叫歷史命令了 

這表示每個使用者的「.bash_history」檔案只可以儲存30條舊命令。 

(2)在"/etc/skel/.bash_logout" 檔案中新增下面這行"rm -f $home/.bash_history" 。這樣,當使用者每次登出時,「.bash_history」檔案都會被刪除。

Linux安全設定

1.更改ssh埠 linux中ssh預設埠為22,為了安全考慮,我們有必要對22埠進行修改.可以通過修改 etc ssh sshd config 的port值,並重啟sshd 服務完成 參考 2.禁止 root 登入ssh a.增加普通使用者 adduser x b.修改 etc ssh sshd ...

Linux安全 安全口令策略設定

命令 vim etc login.defs 預設設定 password aging controls pass max days maximum number of days a password may be used.pass min days minimum number of days al...

linux 下口令安全設定

1 linux系統的使用者帳號策略 auth required lib security isa pam tally.so deny 5 account required pam tally.so 該語句的解釋 密碼最大聯絡登入6次,超過只能聯絡管理員。2 密碼策略 pass max days 99...