新聞中心
Linux操作系統(tǒng)的開(kāi)源性、自由性和高可靠性在全球范圍內(nèi)獲得了廣泛應(yīng)用。不過(guò),為了確保在Linux系統(tǒng)上運(yùn)行的應(yīng)用程序和數(shù)據(jù)的安全,需要一系列安全參數(shù)的加固和配置。本文將介紹幾個(gè)重要的Linux安全參數(shù),以確保系統(tǒng)的安全性和數(shù)據(jù)隱私性。

為企業(yè)提供成都做網(wǎng)站、網(wǎng)站制作、網(wǎng)站優(yōu)化、成都營(yíng)銷網(wǎng)站建設(shè)、競(jìng)價(jià)托管、品牌運(yùn)營(yíng)等營(yíng)銷獲客服務(wù)。成都創(chuàng)新互聯(lián)擁有網(wǎng)絡(luò)營(yíng)銷運(yùn)營(yíng)團(tuán)隊(duì),以豐富的互聯(lián)網(wǎng)營(yíng)銷經(jīng)驗(yàn)助力企業(yè)精準(zhǔn)獲客,真正落地解決中小企業(yè)營(yíng)銷獲客難題,做到“讓獲客更簡(jiǎn)單”。自創(chuàng)立至今,成功用技術(shù)實(shí)力解決了企業(yè)“網(wǎng)站建設(shè)、網(wǎng)絡(luò)品牌塑造、網(wǎng)絡(luò)營(yíng)銷”三大難題,同時(shí)降低了營(yíng)銷成本,提高了有效客戶轉(zhuǎn)化率,獲得了眾多企業(yè)客戶的高度認(rèn)可!
一、物理訪問(wèn)控制
物理訪問(wèn)控制是Linux系統(tǒng)中最基礎(chǔ)的安全控制方法。物理安全措施可以保護(hù)計(jì)算機(jī)免受未經(jīng)授權(quán)的訪問(wèn)、竊取或破壞。例如,在計(jì)算機(jī)房中使用電子門禁系統(tǒng)、監(jiān)控設(shè)備或密碼鎖等安全設(shè)施來(lái)控制物理訪問(wèn)。此外,也應(yīng)定期檢查硬件設(shè)備的完整性,包括硬盤、內(nèi)存等,如果出現(xiàn)損壞或更換的情況,也應(yīng)及時(shí)檢查更換者身份以確保信息安全。
二、訪問(wèn)控制列表
Linux系統(tǒng)中一般采用的訪問(wèn)控制方法有訪問(wèn)控制列表(ACLs)和基于角色的訪問(wèn)控制(RBACs)等。ACLs是用于控制文件和目錄權(quán)限的工具。通過(guò)ACLs,可以對(duì)每個(gè)文件和目錄的訪問(wèn)權(quán)限進(jìn)行單獨(dú)控制。例如,在訪問(wèn)一個(gè)目錄時(shí),需要提供用戶名和密碼來(lái)驗(yàn)證身份,以獲得訪問(wèn)權(quán)限。此外,也可以通過(guò)ACLs對(duì)文件的所有者和組進(jìn)行訪問(wèn)控制。
三、防火墻
防火墻是一種可以防止惡意軟件和網(wǎng)絡(luò)攻擊的工具。Linux系統(tǒng)中常用的防火墻有iptables和firewalld,可以通過(guò)這兩個(gè)工具來(lái)限制進(jìn)入和離開(kāi)系統(tǒng)的網(wǎng)絡(luò)流量。例如,通過(guò)防火墻可以阻止未授權(quán)的訪問(wèn)和黑客攻擊,以保護(hù)系統(tǒng)的安全性。
四、SSL/TLS加密
SSL/TLS加密協(xié)議是一種用于加密網(wǎng)絡(luò)通信的安全協(xié)議。可以將數(shù)據(jù)加密后在網(wǎng)絡(luò)上進(jìn)行傳輸,以防止其他人查看或攔截通信。在Linux系統(tǒng)中,SSL/TLS加密可以應(yīng)用在不同的應(yīng)用程序中,如Apache、Nginx、Postfix等。對(duì)于傳輸敏感信息的網(wǎng)站、電子郵件和其他應(yīng)用程序,使用SSL/TLS加密可以保護(hù)數(shù)據(jù)的安全和隱私。
五、定期備份
定期備份也是保障數(shù)據(jù)安全的一種有效方法。定期備份可以避免數(shù)據(jù)丟失或被破壞的風(fēng)險(xiǎn)。在Linux系統(tǒng)中,可以使用各種備份軟件進(jìn)行定期備份,如rsync、tar等等。此外,還可以將備份文件存儲(chǔ)在本地或遠(yuǎn)程存儲(chǔ)服務(wù)器中,以確保備份數(shù)據(jù)的安全性。
總體上,保護(hù)Linux系統(tǒng)安全和數(shù)據(jù)隱私的最終目的是保護(hù)企業(yè)或個(gè)人在信息化時(shí)代的利益,因此,應(yīng)該采取一系列的有效措施來(lái)加強(qiáng) Linux 系統(tǒng)的安全性。在支持Linux平臺(tái)的企業(yè)環(huán)境中,IT專家和管理員應(yīng)加倍努力,行之有效的 Linux 安全策略能夠?yàn)楣颈U闲畔⒑蛿?shù)據(jù)的安全。
相關(guān)問(wèn)題拓展閱讀:
- selinux常用參數(shù)
selinux常用參數(shù)
1)ls命令
在命令后加個(gè) -Z 或者陵陵加 –context
# ls -Z
-rwxr-xr-x fu fu user_u:object_r:user_home_t azureus
-rw-r–r– fu fu user_u:object_r:user_home_t Azureus2.jar
-rw-r–r– fu fu user_u:object_r:user_home_t Azureus.png
2)chcon
更改文件的標(biāo)簽
# ls –context test.txt
-rw-r–r– root root root:object_r:staff_tmp_t test.txt
# chcon -t etc_t test.txt
# ls -lZ test.txt
-rw-r–r– root root root:object_r:etc_t test.txt
3)restorecon
當(dāng)這個(gè)文件在策略里有定義是,可以恢復(fù)原來(lái)的 文件標(biāo)簽。
4)setfiles
跟chcon一樣可以更改一部分文件的標(biāo)簽,不需要對(duì)整個(gè)文件系統(tǒng)重新設(shè)定標(biāo)簽。
5)fixfiles
一般是對(duì)整個(gè)文件系統(tǒng)的, 后面一般跟 relabel,對(duì)整個(gè)系統(tǒng) relabel后,一般我們都重新啟動(dòng)。如果,在根目錄下有.autorelabel空文件的話,每次重新啟動(dòng)時(shí)都調(diào)用 fixfiles relabel
6)star
就是tar在SELinux下的互換命令,能把文件的標(biāo)簽也一起備份起來(lái)。
7)cp
可以跟 -Z, –context=CONTEXT 在拷貝的時(shí)候指定目的地文件的security context
8)find
可以跟 –context 查特定的type的文件。
例子:
find /home/fu/ –context fu:fu_r:amule_t -exec ls -Z {} \:
9)run_init
在sysadm_t里手動(dòng)啟動(dòng)一些如Apache之類的程序尺攜戚,也可以讓它正常進(jìn)行,domain遷移隱高。
了解和配置 SELinux
1. 獲取當(dāng)前 SELinux 運(yùn)行狀態(tài)
getenforce
可能返回結(jié)果有三種:Enforcing、Permissive 和 Disabled。Disabled 代表 SELinux 被禁用,Permissive 代表僅記錄安全警告但不阻止 可疑行為,Enforcing 代表記錄警告且阻止可疑行為。
目前常見(jiàn)發(fā)行版中,RHEL、CentOS、Fedora 等默認(rèn)設(shè)置為 Enforcing,其余的如 openSUSE 等為 Permissive。
2. 改變 SELinux 運(yùn)行狀態(tài)
setenforce
該命令可以立刻改變 SELinux 運(yùn)行狀態(tài),在 Enforcing 和 Permissive 之間切換,結(jié)果保持至關(guān)機(jī)。一個(gè)典型的如指搏用途是看看到底是不是 SELinux 導(dǎo)致某個(gè)服務(wù)或者程序無(wú)法運(yùn)行。若是在 setenforce 0 之后服務(wù)或者程序依然無(wú)法運(yùn)行,那么就可以肯定不是 SELinux 導(dǎo)致的。
若是想要永久變更系統(tǒng) SELinux 運(yùn)行環(huán)境,可以通過(guò)更改配置文件 /etc/selinux/config 實(shí)現(xiàn)。注意當(dāng)從 Disabled 切換到 Permissive 或者 Enforcing 模式后需要重啟計(jì)算機(jī)并為整個(gè)文件系統(tǒng)重新創(chuàng)建安全標(biāo)簽(touch /.autorelabel && reboot)。
# vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these two values:
# targeted – Targeted processes are protected,
# mls – Multi Level Security protection.
SELINUXTYPE=targeted
3. SELinux 運(yùn)行策略
配置文件 /etc/selinux/config 還包含了 SELinux 運(yùn)行策略的信息,通過(guò)改變變量 SELINUXTYPE 的值實(shí)現(xiàn),該值有兩種可能: targeted 代表僅針對(duì)預(yù)制的幾種網(wǎng)絡(luò)服務(wù)和逗蠢訪問(wèn)請(qǐng)求使用 SELinux 保護(hù),strict 代表所有網(wǎng)絡(luò)服務(wù)和訪問(wèn)請(qǐng)求都要經(jīng)過(guò) SELinux。
RHEL、CentOS、Fedora 等默認(rèn)設(shè)渣祥置為 targeted,包含了對(duì)幾乎所有常見(jiàn)網(wǎng)絡(luò)服務(wù)的 SELinux 策略配置,已經(jīng)默認(rèn)安裝并且可以無(wú)需修改直接使用。 若是想自己編輯 SELinux 策略,也提供了命令行下的策略編輯器 seedit 以及 Eclipse 下的編輯插件 eclipse-slide 。
4. coreutils 工具的 SELinux 模式
常見(jiàn)的屬于 coreutils 的工具如 ps、ls 等等,可以通過(guò)增加 Z 選項(xiàng)的方式獲知 SELinux 方面的信息。
4.1使用ps獲?。?/p>
$ ps -auxZ |grep httpd |head -5
Warning: bad syntax, perhaps a bogus ‘-‘? See /usr/share/doc/procps-3.2.8/FAQ unconfined_u:system_r:httpd_t:s0 apache.0 0.? S Jun27 0:01 /usr/in/httpd unconfined_u:system_r:httpd_t:s0 apache.0 1. ? S Jun27 0:02 /usr/in/httpd unconfined_u:system_r:httpd_t:s0 apache.0 1. ? S Jun27 0:02 /usr/in/httpd unconfined_u:system_r:httpd_t:s0 apache.0 1. ? S Jun27 0:02 /usr/in/httpd unconfined_u:system_r:httpd_t:s0 apache.0 1. ? S Jun27 0:03 /usr/in/httpd
4.2使用ls獲取
$ ls -Z /var/www/ drwxrwxrwx. apache barlow unconfined_u:object_r:httpd_sys_script_exec_t:s0 cgi-bin drwxrwxrwx. apache barlow unconfined_u:object_r:httpd_sys_content_t:s0 error drwxrwxrwx. apache barlow unconfined_u:object_r:httpd_sys_content_t:s0 html drwxrwxrwx. apache barlow unconfined_u:object_r:httpd_sys_content_t:s0 icons drwxrwxrwx. apache barlow system_u:object_r:httpd_sys_content_t:s0 lost+found
以此類推,Z 選項(xiàng)可以應(yīng)用在幾乎全部 coreutils 工具里。
5、常用修改有關(guān)httpd服務(wù)的SELinux策略方法:
如上,ls -Z方法查詢到的文件SELinux上下文跟默認(rèn)要求的不匹配,則服務(wù)無(wú)法正常使用,如SELinux要求httpd服務(wù)的網(wǎng)頁(yè)目錄或文件的上 下文要為httpd_sys_content_t,否則客戶端無(wú)法訪問(wèn)。
5.1使用chcon修改httpd目錄或文件安全上下文:
如nagios服務(wù)器的網(wǎng)頁(yè)目錄上下文默認(rèn)為unconfined_u:object_r:usr_t:s0,則客戶端無(wú)法訪問(wèn):
# ll -Z /usr/local/nagios/share/
-rwxrwxr-x. nagios apache system_u:object_r:usr_t:s0 config.inc.php
drwxrwxr-x. nagios apache unconfined_u:object_r:usr_t:s0 contexthelp
drwxrwxr-x. nagios apache unconfined_u:object_r:usr_t:s0 docs
drwxrwxr-x. nagios apache unconfined_u:object_r:usr_t:s0 images
drwxrwxr-x. nagios apache unconfined_u:object_r:usr_t:s0 includes
-rwxrwxr-x. nagios apache system_u:object_r:usr_t:s0 index.html
-rwxrwxr-x. nagios apache system_u:object_r:usr_t:s0 index.php
……以下略……
使用chcon修改/usr/local/nagios/share/目錄及其下所有文件安全上下文為unconfined_u:object_r:httpd_sys_content_t
# chcon -R unconfined_u:object_r:httpd_sys_content_t:s0 /usr/local/nagios/share/
查詢結(jié)果:
# ls -Z /usr/local/nagios/share/
-rwxrwxr-x. nagios apache unconfined_u:object_r:httpd_sys_content_t:s0 config.inc.php
drwxrwxr-x. nagios apache unconfined_u:object_r:httpd_sys_content_t:s0 contexthelp
drwxrwxr-x. nagios apache unconfined_u:object_r:httpd_sys_content_t:s0 docs
drwxrwxr-x. nagios apache unconfined_u:object_r:httpd_sys_content_t:s0 images
drwxrwxr-x. nagios apache unconfined_u:object_r:httpd_sys_content_t:s0 includes
-rwxrwxr-x. nagios apache unconfined_u:object_r:httpd_sys_content_t:s0 index.html
-rwxrwxr-x. nagios apache unconfined_u:object_r:httpd_sys_content_t:s0 index.php
drwxrwxr-x. nagios apache unconfined_u:object_r:httpd_sys_content_t:s0 locale
-rwxrwxr-x. nagios apache unconfined_u:object_r:httpd_sys_content_t:s0 main.html
不用重啟httpd服務(wù),客戶端就已經(jīng)可以訪問(wèn)。
5.2使用semanage工具,讓httpd支持非標(biāo)準(zhǔn)端口:
semanage工具非常強(qiáng)大,基本能實(shí)現(xiàn)所有SELinux配置,但很多時(shí)候我們并不知道SELinux錯(cuò)在哪里,在圖形界面下有圖形化的分析工具,在 終端界面下也有一個(gè)功能非常強(qiáng)大的分析工具sealert,但默認(rèn)情況下,這兩個(gè)工具都沒(méi)有被安裝,需要先安裝semanage和sealert工具:
# yum -y install policycoreutils-python setroubleshoot
注:semanage的使用也可以參見(jiàn)我的另外一篇博文:Selinux管理工具semanage。
默認(rèn)情況下 Apache 只偵聽(tīng) 80、443等幾個(gè)端口,若是直接指定其偵聽(tīng) 808 端口的話,會(huì)在 service httpd restart 的時(shí)候報(bào)錯(cuò):
# service httpd start
正在啟動(dòng) httpd:(13)Permission denied: make_sock: could not bind to address 0.0.0.0:808
no listening sockets available, shutting down
Unable to open logs
查看/var/log/messages 文件,可以看到如下這樣的錯(cuò)誤:
# tail /var/log/messages
Jun 29 10:30:51 web2 setroubleshoot: SELinux is preventing /usr/in/httpd from name_bind access on the tcp_socket . For complete SELinux messages. run sealert -l 2ad073a4-7cff-9d78f75133af
根據(jù)提示,運(yùn)行sealert -l 2ad073a4-7cff-9d78f75133af,生成SELinux報(bào)告如下:
# sealert -l 2ad073a4-7cff-9d78f75133af
# semanage port -a -t PORT_TYPE -p tcp 808
其中 PORT_TYPE 是以下之一:ntop_port_t, http_cache_port_t, http_port_t, puppet_port_t, jboss_messaging_port_t, jboss_management_port_t。
根據(jù)提示,運(yùn)行semanage port -a -t PORT_TYPE -p tcp 808,此處需將PORT_TYPE替換為 http_port_t
# semanage port -a -t http_port_t -p tcp 808
查詢結(jié)果:
# semanage port -l|grep http
http_cache_port_t tcp 3128, 8080, 8118, 8123,
http_cache_port_t udp 3130
http_port_t tcp 808, 80, 443, 488, 8008, 8009,##可以看到808端口已經(jīng)加入
pegasus_http_port_t tcp 5988
pegasus_https_port_t tcp 5989
重啟服務(wù):
# service httpd start
正在啟動(dòng) httpd:
5.3 修改selinux布爾值,允許創(chuàng)建私人網(wǎng)站
若是希望用戶可以通過(guò)在 ~/www/ 放置文件的方式創(chuàng)建自己的個(gè)人網(wǎng)站的話,那么需要在 Apache 策略中允許該操作執(zhí)行。使用:
# setsebool httpd_enable_homedirs 1
默認(rèn)情況下 setsebool 的設(shè)置只保留到下一次重啟之前,若是想永久生效的話,需要添加 -P 參數(shù),比如:
# setsebool -P httpd_enable_homedirs 1
setsebool 是用來(lái)切換由布爾值控制的 SELinux 策略的,當(dāng)前布爾值策略的狀態(tài)可以通過(guò) getsebool 來(lái)獲知。 查看與httpd相關(guān)的布爾值:
# getsebool -a |grep http
allow_httpd_anon_write –> off
allow_httpd_mod_auth_ntlm_winbind –> off
allow_httpd_mod_auth_pam –> off
allow_httpd_sys_script_anon_write –> off
httpd_builtin_scripting –> on
httpd_can_check_spam –> off
httpd_can_network_connect –> off
httpd_can_network_connect_cobbler –> off
httpd_can_network_connect_db –> on
httpd_can_network_memcache –> off
httpd_can_network_relay –> off
httpd_can_sendmail –> off
httpd_dbus_avahi –> on
httpd_enable_cgi –> on
httpd_enable_ftp_server –> off
httpd_enable_homedirs –> on
httpd_execmem –> off
httpd_manage_ipa –> off
httpd_read_user_content –> off
httpd_run_stickshift –> off
httpd_setrlimit –> off
httpd_ssi_exec –> off
httpd_tmp_exec –> off
httpd_tty_comm –> on
httpd_unified –> on
httpd_use_cifs –> off
httpd_use_gpg –> off
httpd_use_nfs –> on
httpd_use_openstack –> off
httpd_verify_dns –> off
named_bind_http_port –> off
linux的安全參數(shù)的介紹就聊到這里吧,感謝你花時(shí)間閱讀本站內(nèi)容,更多關(guān)于linux的安全參數(shù),解密Linux安全參數(shù):保障系統(tǒng)安全,保護(hù)數(shù)據(jù)隱私,selinux常用參數(shù)的信息別忘了在本站進(jìn)行查找喔。
成都創(chuàng)新互聯(lián)科技有限公司,是一家專注于互聯(lián)網(wǎng)、IDC服務(wù)、應(yīng)用軟件開(kāi)發(fā)、網(wǎng)站建設(shè)推廣的公司,為客戶提供互聯(lián)網(wǎng)基礎(chǔ)服務(wù)!
創(chuàng)新互聯(lián)(www.cdcxhl.com)提供簡(jiǎn)單好用,價(jià)格厚道的香港/美國(guó)云服務(wù)器和獨(dú)立服務(wù)器。創(chuàng)新互聯(lián)成都老牌IDC服務(wù)商,專注四川成都IDC機(jī)房服務(wù)器托管/機(jī)柜租用。為您精選優(yōu)質(zhì)idc數(shù)據(jù)中心機(jī)房租用、服務(wù)器托管、機(jī)柜租賃、大帶寬租用,可選線路電信、移動(dòng)、聯(lián)通等。
網(wǎng)站標(biāo)題:解密Linux安全參數(shù):保障系統(tǒng)安全,保護(hù)數(shù)據(jù)隱私(linux的安全參數(shù))
URL標(biāo)題:http://www.dlmjj.cn/article/coddede.html


咨詢
建站咨詢
