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

為企業(yè)提供成都做網(wǎng)站、網(wǎng)站制作、網(wǎng)站優(yōu)化、成都營銷網(wǎng)站建設(shè)、競價托管、品牌運營等營銷獲客服務(wù)。成都創(chuàng)新互聯(lián)擁有網(wǎng)絡(luò)營銷運營團隊,以豐富的互聯(lián)網(wǎng)營銷經(jīng)驗助力企業(yè)精準獲客,真正落地解決中小企業(yè)營銷獲客難題,做到“讓獲客更簡單”。自創(chuàng)立至今,成功用技術(shù)實力解決了企業(yè)“網(wǎng)站建設(shè)、網(wǎng)絡(luò)品牌塑造、網(wǎng)絡(luò)營銷”三大難題,同時降低了營銷成本,提高了有效客戶轉(zhuǎn)化率,獲得了眾多企業(yè)客戶的高度認可!
一、物理訪問控制
物理訪問控制是Linux系統(tǒng)中最基礎(chǔ)的安全控制方法。物理安全措施可以保護計算機免受未經(jīng)授權(quán)的訪問、竊取或破壞。例如,在計算機房中使用電子門禁系統(tǒng)、監(jiān)控設(shè)備或密碼鎖等安全設(shè)施來控制物理訪問。此外,也應(yīng)定期檢查硬件設(shè)備的完整性,包括硬盤、內(nèi)存等,如果出現(xiàn)損壞或更換的情況,也應(yīng)及時檢查更換者身份以確保信息安全。
二、訪問控制列表
Linux系統(tǒng)中一般采用的訪問控制方法有訪問控制列表(ACLs)和基于角色的訪問控制(RBACs)等。ACLs是用于控制文件和目錄權(quán)限的工具。通過ACLs,可以對每個文件和目錄的訪問權(quán)限進行單獨控制。例如,在訪問一個目錄時,需要提供用戶名和密碼來驗證身份,以獲得訪問權(quán)限。此外,也可以通過ACLs對文件的所有者和組進行訪問控制。
三、防火墻
防火墻是一種可以防止惡意軟件和網(wǎng)絡(luò)攻擊的工具。Linux系統(tǒng)中常用的防火墻有iptables和firewalld,可以通過這兩個工具來限制進入和離開系統(tǒng)的網(wǎng)絡(luò)流量。例如,通過防火墻可以阻止未授權(quán)的訪問和黑客攻擊,以保護系統(tǒng)的安全性。
四、SSL/TLS加密
SSL/TLS加密協(xié)議是一種用于加密網(wǎng)絡(luò)通信的安全協(xié)議??梢詫?shù)據(jù)加密后在網(wǎng)絡(luò)上進行傳輸,以防止其他人查看或攔截通信。在Linux系統(tǒng)中,SSL/TLS加密可以應(yīng)用在不同的應(yīng)用程序中,如Apache、Nginx、Postfix等。對于傳輸敏感信息的網(wǎng)站、電子郵件和其他應(yīng)用程序,使用SSL/TLS加密可以保護數(shù)據(jù)的安全和隱私。
五、定期備份
定期備份也是保障數(shù)據(jù)安全的一種有效方法。定期備份可以避免數(shù)據(jù)丟失或被破壞的風(fēng)險。在Linux系統(tǒng)中,可以使用各種備份軟件進行定期備份,如rsync、tar等等。此外,還可以將備份文件存儲在本地或遠程存儲服務(wù)器中,以確保備份數(shù)據(jù)的安全性。
總體上,保護Linux系統(tǒng)安全和數(shù)據(jù)隱私的最終目的是保護企業(yè)或個人在信息化時代的利益,因此,應(yīng)該采取一系列的有效措施來加強 Linux 系統(tǒng)的安全性。在支持Linux平臺的企業(yè)環(huán)境中,IT專家和管理員應(yīng)加倍努力,行之有效的 Linux 安全策略能夠為公司保障信息和數(shù)據(jù)的安全。
相關(guān)問題拓展閱讀:
- selinux常用參數(shù)
selinux常用參數(shù)
1)ls命令
在命令后加個 -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
更改文件的標簽
# 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
當這個文件在策略里有定義是,可以恢復(fù)原來的 文件標簽。
4)setfiles
跟chcon一樣可以更改一部分文件的標簽,不需要對整個文件系統(tǒng)重新設(shè)定標簽。
5)fixfiles
一般是對整個文件系統(tǒng)的, 后面一般跟 relabel,對整個系統(tǒng) relabel后,一般我們都重新啟動。如果,在根目錄下有.autorelabel空文件的話,每次重新啟動時都調(diào)用 fixfiles relabel
6)star
就是tar在SELinux下的互換命令,能把文件的標簽也一起備份起來。
7)cp
可以跟 -Z, –context=CONTEXT 在拷貝的時候指定目的地文件的security context
8)find
可以跟 –context 查特定的type的文件。
例子:
find /home/fu/ –context fu:fu_r:amule_t -exec ls -Z {} \:
9)run_init
在sysadm_t里手動啟動一些如Apache之類的程序尺攜戚,也可以讓它正常進行,domain遷移隱高。
了解和配置 SELinux
1. 獲取當前 SELinux 運行狀態(tài)
getenforce
可能返回結(jié)果有三種:Enforcing、Permissive 和 Disabled。Disabled 代表 SELinux 被禁用,Permissive 代表僅記錄安全警告但不阻止 可疑行為,Enforcing 代表記錄警告且阻止可疑行為。
目前常見發(fā)行版中,RHEL、CentOS、Fedora 等默認設(shè)置為 Enforcing,其余的如 openSUSE 等為 Permissive。
2. 改變 SELinux 運行狀態(tài)
setenforce
該命令可以立刻改變 SELinux 運行狀態(tài),在 Enforcing 和 Permissive 之間切換,結(jié)果保持至關(guān)機。一個典型的如指搏用途是看看到底是不是 SELinux 導(dǎo)致某個服務(wù)或者程序無法運行。若是在 setenforce 0 之后服務(wù)或者程序依然無法運行,那么就可以肯定不是 SELinux 導(dǎo)致的。
若是想要永久變更系統(tǒng) SELinux 運行環(huán)境,可以通過更改配置文件 /etc/selinux/config 實現(xiàn)。注意當從 Disabled 切換到 Permissive 或者 Enforcing 模式后需要重啟計算機并為整個文件系統(tǒng)重新創(chuàng)建安全標簽(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 運行策略
配置文件 /etc/selinux/config 還包含了 SELinux 運行策略的信息,通過改變變量 SELINUXTYPE 的值實現(xiàn),該值有兩種可能: targeted 代表僅針對預(yù)制的幾種網(wǎng)絡(luò)服務(wù)和逗蠢訪問請求使用 SELinux 保護,strict 代表所有網(wǎng)絡(luò)服務(wù)和訪問請求都要經(jīng)過 SELinux。
RHEL、CentOS、Fedora 等默認設(shè)渣祥置為 targeted,包含了對幾乎所有常見網(wǎng)絡(luò)服務(wù)的 SELinux 策略配置,已經(jīng)默認安裝并且可以無需修改直接使用。 若是想自己編輯 SELinux 策略,也提供了命令行下的策略編輯器 seedit 以及 Eclipse 下的編輯插件 eclipse-slide 。
4. coreutils 工具的 SELinux 模式
常見的屬于 coreutils 的工具如 ps、ls 等等,可以通過增加 Z 選項的方式獲知 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 選項可以應(yīng)用在幾乎全部 coreutils 工具里。
5、常用修改有關(guān)httpd服務(wù)的SELinux策略方法:
如上,ls -Z方法查詢到的文件SELinux上下文跟默認要求的不匹配,則服務(wù)無法正常使用,如SELinux要求httpd服務(wù)的網(wǎng)頁目錄或文件的上 下文要為httpd_sys_content_t,否則客戶端無法訪問。
5.1使用chcon修改httpd目錄或文件安全上下文:
如nagios服務(wù)器的網(wǎng)頁目錄上下文默認為unconfined_u:object_r:usr_t:s0,則客戶端無法訪問:
# 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)可以訪問。
5.2使用semanage工具,讓httpd支持非標準端口:
semanage工具非常強大,基本能實現(xiàn)所有SELinux配置,但很多時候我們并不知道SELinux錯在哪里,在圖形界面下有圖形化的分析工具,在 終端界面下也有一個功能非常強大的分析工具sealert,但默認情況下,這兩個工具都沒有被安裝,需要先安裝semanage和sealert工具:
# yum -y install policycoreutils-python setroubleshoot
注:semanage的使用也可以參見我的另外一篇博文:Selinux管理工具semanage。
默認情況下 Apache 只偵聽 80、443等幾個端口,若是直接指定其偵聽 808 端口的話,會在 service httpd restart 的時候報錯:
# service httpd start
正在啟動 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 文件,可以看到如下這樣的錯誤:
# 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ù)提示,運行sealert -l 2ad073a4-7cff-9d78f75133af,生成SELinux報告如下:
# 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ù)提示,運行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
正在啟動 httpd:
5.3 修改selinux布爾值,允許創(chuàng)建私人網(wǎng)站
若是希望用戶可以通過在 ~/www/ 放置文件的方式創(chuàng)建自己的個人網(wǎng)站的話,那么需要在 Apache 策略中允許該操作執(zhí)行。使用:
# setsebool httpd_enable_homedirs 1
默認情況下 setsebool 的設(shè)置只保留到下一次重啟之前,若是想永久生效的話,需要添加 -P 參數(shù),比如:
# setsebool -P httpd_enable_homedirs 1
setsebool 是用來切換由布爾值控制的 SELinux 策略的,當前布爾值策略的狀態(tài)可以通過 getsebool 來獲知。 查看與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ù)的介紹就聊到這里吧,感謝你花時間閱讀本站內(nèi)容,更多關(guān)于linux的安全參數(shù),解密Linux安全參數(shù):保障系統(tǒng)安全,保護數(shù)據(jù)隱私,selinux常用參數(shù)的信息別忘了在本站進行查找喔。
成都創(chuàng)新互聯(lián)科技有限公司,是一家專注于互聯(lián)網(wǎng)、IDC服務(wù)、應(yīng)用軟件開發(fā)、網(wǎng)站建設(shè)推廣的公司,為客戶提供互聯(lián)網(wǎng)基礎(chǔ)服務(wù)!
創(chuàng)新互聯(lián)(www.cdcxhl.com)提供簡單好用,價格厚道的香港/美國云服務(wù)器和獨立服務(wù)器。創(chuàng)新互聯(lián)成都老牌IDC服務(wù)商,專注四川成都IDC機房服務(wù)器托管/機柜租用。為您精選優(yōu)質(zhì)idc數(shù)據(jù)中心機房租用、服務(wù)器托管、機柜租賃、大帶寬租用,可選線路電信、移動、聯(lián)通等。
網(wǎng)站題目:解密Linux安全參數(shù):保障系統(tǒng)安全,保護數(shù)據(jù)隱私(linux的安全參數(shù))
分享URL:http://www.5511xx.com/article/coddede.html


咨詢
建站咨詢
