當前位置:首頁 » 密碼管理 » linux訪問控制

linux訪問控制

發布時間: 2022-08-14 23:51:02

linux SAMBA伺服器配置共享目錄,訪問控制,用戶映射

[global]

# ----------------------- Network Related Options-------------------------
#
# workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH
#
# server string is the equivalent of the NT Description field
#
# netbios name can be used to specify a server name not tied to thehostname
#
# Interfaces lets you configure Samba to use multiple interfaces
# If you have multiple network interfaces then you can list the ones
# you want to listen on (never omit localhost)
#
# Hosts Allow/Hosts Deny lets you restrict who can connect, and you can
# specifiy it as a per share option as well
#
workgroup = MYGROUP
server string = Samba Server Version%v

; netbios name = MYSERVER

interfaces = lo eth0
hosts allow = 192.168.1.
user map =/etc/samba/smbusermap

# --------------------------- Logging Options-----------------------------
#
# Log File let you specify where to put logs and how to split them up.
#
# Max Log Size let you specify the max size log files should reach

# logs split per machine
log file = /var/log/samba/log.%m
# max 50KB per log file, thenrotate
max log size = 50

# ----------------------- Standalone Server Options------------------------
#
# Scurity can be set to user, share(deprecated) or server(deprecated)
#
# Backend to store user information in. New installations should
# use either tdbsam or ldapsam. smbpasswd is available for backwards
# compatibility. tdbsam requires no further configuration.

security = user
passdb backend = tdbsam

# ----------------------- Domain Members Options ------------------------
#
# Security must be set to domain or ads
#
# Use the realm option only with security = ads
# Specifies the Active Directory realm the host is part of
#
# Backend to store user information in. New installations should
# use either tdbsam or ldapsam. smbpasswd is available for backwards
# compatibility. tdbsam requires no further configuration.
#
# Use password server option only with security = server or if you can't
# use the DNS to locate Domain Controllers
# The argument list may include:
# password server = My_PDC_Name[My_BDC_Name] [My_Next_BDC_Name]
# or to auto-locate the domain controller/s
# password server = *

; security = domain
; passdb backend = tdbsam
; realm = MY_REALM

; password server =<NT-Server-Name>

# ----------------------- Domain Controller Options------------------------
#
# Security must be set to user for domain controllers
#
# Backend to store user information in. New installations should
# use either tdbsam or ldapsam. smbpasswd is available for backwards
# compatibility. tdbsam requires no further configuration.
#
# Domain Master specifies Samba to be the Domain Master Browser. This
# allows Samba to collate browse lists between subnets. Don't use this
# if you already have a Windows NT domain controller doing this job
#
# Domain Logons let Samba be a domain logon server for Windows workstations.
#
# Logon Scrpit let yuou specify a script to be run at login time on theclient
# You need to provide it in a share called NETLOGON
#
# Logon Path let you specify where user profiles are stored (UNC path)
#
# Various scripts can be used on a domain controller or stand-alone
# machine to add or delete corresponding unix accounts
#
; security = user
; passdb backend = tdbsam

; domain master = yes
; domain logons = yes

# the login script name depends on themachine name
; logon script = %m.bat
# the login script name depends on theunix user used
; logon script = %u.bat
; logon path = \\%L\Profiles\%u
# disables profiles support byspecifing an empty path
; logon path =

; add user script = /usr/sbin/useradd"%u" -n -g users
; add group script = /usr/sbin/groupadd"%g"
; add machine script = /usr/sbin/useradd-n -c "Workstation (%u)" -M -d /nohome -s /bin/false"%u"
; delete user script = /usr/sbin/userdel"%u"
; delete user from group script =/usr/sbin/userdel "%u" "%g"
; delete group script =/usr/sbin/groupdel "%g"

# ----------------------- Browser Control Options----------------------------
#
# set local master to no if you don't want Samba to become a master
# browser on your network. Otherwise the normal election rules apply
#
# OS Level determines the precedence of this server in master browser
# elections. The default value should be reasonable
#
# Preferred Master causes Samba to force a local browser election onstartup
# and gives it a slightly higher chance of winning the election
; local master = no
; os level = 33
; preferred master = yes

#----------------------------- Name Resolution -------------------------------
# Windows Internet Name Serving Support Section:
# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
#
# - WINS Support: Tells the NMBD component of Samba to enable it's WINSServer
#
# - WINS Server: Tells the NMBD components of Samba to be a WINS Client
#
# - WINS Proxy: Tells Samba to answer name resolution queries on
# behalf of a non WINS capable client,for this to work there must be
# at least one WINS Server on the network. The default is NO.
#
# DNS Proxy - tells Samba whether or not to try to resolve NetBIOS names
# via DNS nslookups.

; wins support = yes
; wins server = w.x.y.z
; wins proxy = yes

; dns proxy = yes

# --------------------------- Printing Options-----------------------------
#
# Load Printers let you load automatically the list of printers rather
# than setting them up indivially
#
# Cups Options let you pass the cups libs custom options, setting it toraw
# for example will let you use drivers on your Windows clients
#
# Printcap Name let you specify an alternative printcap file
#
# You can choose a non default printing system using the Printing option

load printers = no
cups options = raw

; printcap name = /etc/printcap
#obtain list of printers automaticallyon SystemV
; printcap name = lpstat
; printing = cups

# --------------------------- Filesystem Options---------------------------
#
# The following options can be uncommented if the filesystem supports
# Extended Attributes and they are enabled (usually by the mount option
# user_xattr). Thess options will let the admin store the DOS attributes
# in an EA and make samba not mess with the permission bits.
#
# Note: these options can also be set just per share, setting them inglobal
# makes them the default for all shares

; map archive = no
; map hidden = no
; map read only = no
; map system = no
; store dos attributes = yes

#============================ Share Definitions==============================

[homes]
comment = Home Directories
browseable = no
writable = yes
; valid users = %S
; valid users = MYDOMAIN\%S

[sales]
comment = Home Directories
path=/var/samba/sales
browseable = no
writable = yes
; valid users = %S
; valid users = MYDOMAIN\%S

[finance]
comment = Home Directories
browseable = yes
path=/var/samba/finance
writable = yes
; valid users = %S
; valid users = MYDOMAIN\%S

[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes

# Un-comment the following and create the netlogon directory for DomainLogons
; [netlogon]
; comment = Network Logon Service
; path = /var/lib/samba/netlogon
; guest ok = yes
; writable = no
; share modes = no

# Un-comment the following to provide a specific roving profile share
# the default is to use the user's home directory
; [Profiles]
; path = /var/lib/samba/profiles
; browseable = no
; guest ok = yes

# A publicly accessible directory, but read only, except for people in
# the "staff" group
; [public]
; comment = Public Stuff
; path = /home/samba
; public = yes
; writable = yes
; printable = no
; write list = +staff

以上是smb.conf內的配置。
增加用戶和組,並設置好用戶組的隸屬關系。
用smbpasswd -a 增加smb訪問密碼。

② linux設置文件的許可權

文件的三個最基本的許可權是讀寫執行
r,讀,可以讀取文件,對目錄來說可以列出目錄的文件列表
4
w,寫,可以修改刪除文件,對目錄來說可以創建刪除文件
2
x,執行,可以執行文件,對目錄來說可以cd進入目錄
1
注意點:目錄上只有執行許可權,則可以進入或者穿越此文件夾,但是要訪問此文件夾下有讀取許可權的文件,則必須輸入文件名,只有執行許可權的文件夾,不能列出目錄,也不能刪除目錄
特殊位,SUID,SGID,stickt-bit位,如果設置了SUID的可執行文件被執行的,文件將以所有者的身份來運行。SGID,意思同SUID,sticky-bit位,盡管其他用戶有寫許可權,但是必須由屬主執行刪除和移動操作。子目錄也只有屬主可以操作。
許可權設置命令
chmod,-R,遞歸,s表示SUID或者SGID,t表示stick-bit,
chown,改變用戶屬主和組,-R遞歸,加:則是改變組,不加是改變用戶,
umask,設置文件默認生成編碼,就是創建一個新文件的時候的默認許可權,-S查看默認許可權。
find,查找文件,<起始目錄><選項表達式><條件匹配表達式><動作表達式>
選項表達式,-follow,遇到符號鏈接則跟蹤符號鏈接。-regextype指定-regex和-iregex使用的正則表達式的類型,-depth,查找子目錄之前先查找完當前目錄,-mount,不跨越文件系統,-xdev,同-mount,-maxdepth,最大深度查詢,
條件匹配表達式,-name
匹配文件名
-iname匹配文件名不區分大小寫,
-lname匹配符號鏈接文件名,
-ilname匹配符號鏈接文件名不區分大小寫,-path路徑,-regex,正則匹配,-iregex,正則匹配,不區分大小寫,-amin
N查找N分鍾之前被訪問過的所有文件,-atime
N
查找N天之前被訪問的文件,-cmin,和-ctime是文件狀態被修改過的(比如許可權),-mmin和-mtime是文件內容被修改過的,-uid
N查找uid是N的文件,-gid,查找gid是N的所有的文件,-inum,查找i-node是N的文件,-links
N,查找硬鏈接為N的文件,-size
N[bcwkMG]按照大小查找,-perm
MODE按照許可權查找,
-perm
-MODE,按照最低許可權查找,
-anewer
file,查找比file訪問時間新的文件,
-cnewer查找比fule新的修改時間的文件,
-newer
file查找比file新的內容修改過的文件,
-fstype指定類型的文件系統,-type指定文件類型,-empty內容為空,-user
NAME,按照用戶查找,-group按照組查找,-nouser,文件不屬於/etc/passwd中的用戶,-nogroup,文件不屬於/etc/group中的組
動作表達式,-print,每行一個文件,-print0取消間隔符。
grep
[options]
PATTERN
[FIFL...]所有文本內容,把匹配的行列印出來,-c只顯示匹配的次數,-i搜索時不區分大小寫,-n匹配行的行號,-v輸出不匹配的行,-A同時顯示匹配到的行後面的N行,-B匹配輸出行前面幾行,-C匹配輸出行前後各幾行,

③ linux系統的訪問控制機制內容有哪些如何闡述

在linux系統下有iptables hosts.allow文件。 selinux等。

④ 可以通過以下哪些方法,可以來限制對linux系統服務的訪問

這里提出三個解決方案。

第一種:使用chmod更改特定目錄的許可權。這能起到限制特定目錄被某些人訪問的作用,限定某個用戶的目的也能達到,但是會誤傷其他用戶。
第二種:使用linux容器,例如lxc。耗費空間,設置稍顯麻煩。
第三種:使用setfacl命令設定訪問控制。

⑤ 如何在Linux下設置訪問控制列表(ACL)來控制用戶的許可權

Linux下的訪問控制列表(ACL)主要用來控制用戶的許可權,可以做到不同用戶對同一文件有不同的許可權,那麼具體要如何操作呢?下面小編就教你如何在Linux下設置訪問控制列表(ACL)來控制用戶的許可權。

使用擁有許可權控制的Liunx,工作是一件輕松的任務。它可以定義任何user,group和other的許可權。無論是在桌面電腦或者不會有很多用戶的虛擬Linux實例,或者當用戶不願意分享他們之間的文件時,這樣的工作是很棒的。然而,如果你是在一個大型組織,你運行了NFS或者Samba服務給不同的用戶,然後你將會需要靈活的挑選並設置很多復雜的配置和許可權去滿足你的組織不同的需求。

Linux(和其他Unix等POSIX兼容的操作系統)有一種被稱為訪問控制列表(ACL)的許可權控制方法,它是一種許可權分配之外的普遍範式。例如,默認情況下你需要確認3個許可權組:owner、group和other。而使用ACL,你可以增加許可權給其他用戶或組別,而不單只是簡單的「other」或者是擁有者不存在的組別。可以允許指定的用戶A、B、C擁有寫許可權而不再是讓他們整個組擁有寫許可權。

ACL支持多種Linux文件系統,包括ext2, ext3, ext4, XFS, Btfrs, 等。如果你不確定你的文件系統是否支持ACL,請參考文檔。

在文件系統使ACL生效

首先,我們需要安裝工具來管理ACL。

Ubuntu/Debian 中:

$ sudo apt-get install acl

CentOS/Fedora/RHEL 中:

# yum -y install acl

Archlinux 中:

# pacman -S acl

出於演示目的,我將使用ubuntu server版本,其他版本類似。

安裝ACL完成後,需要激活我們磁碟分區的ACL功能,這樣我們才能使用它。

首先,我們檢查ACL功能是否已經開啟。

$ mount

你可以注意到,我的root分區中ACL屬性已經開啟。萬一你沒有開啟,你需要編輯/etc/fstab文件,在你需要開啟ACL的分區的選項前增加acl標記。

現在我們需要重新掛載分區(我喜歡完全重啟,因為我不想丟失數據),如果你對其它分區開啟ACL,你必須也重新掛載它。

$ sudo mount / -o remount

乾的不錯!現在我們已經在我們的系統中開啟ACL,讓我們開始和它一起工作。

ACL 範例

基礎ACL通過兩條命令管理:setfacl用於增加或者修改ACL,getfacl用於顯示分配完的ACL。讓我們來做一些測試。

我創建一個目錄/shared給一個假設的用戶,名叫freeuser

$ ls -lh /

我想要分享這個目錄給其他兩個用戶test和test2,一個擁有完整許可權,另一個只有讀許可權。

首先,為用戶test設置ACL:

$ sudo setfacl -m u:test:rwx /shared

現在用戶test可以隨意創建文件夾,文件和訪問在/shared目錄下的任何地方。

現在我們增加只讀許可權給用戶test2:

$ sudo setfacl -m u:test2:rx /shared

注意test2讀取目錄需要執行(x)許可權

讓我來解釋下setfacl命令格式:

-m 表示修改ACL。你可以增加新的,或修改存在的ACLu: 表示用戶。你可以使用 g 來設置組許可權test 用戶名:rwx 需要設置的許可權。

現在讓我向你展示如何讀取ACL:

$ ls -lh /shared

你可以注意到,正常許可權後多一個+標記。這表示ACL已經設置成功。要具體看一下ACL,我們需要運行:

$ sudo getfacl /shared

最後,如果你需要移除ACL:

$ sudo setfacl -x u:test /shared

如果你想要立即擦除所有ACL條目:

$ sudo setfacl -b /shared

最後,在設置了ACL文件或目錄工作時,cp和mv命令會改變這些設置。在cp的情況下,需要添加「p」參數來復制ACL設置。如果這不可行,它將會展示一個警告。mv默認移動ACL設置,如果這也不可行,它也會向您展示一個警告。

總結

使用ACL讓在你想要分享的文件上擁有更多的能力和控制,特別是在NFS/Samba服務。此外,如果你的主管共享主機,這個工具是必備的。

上面就是Linux下設置訪問控制列表來控制用戶許可權的方法介紹了,因為ACL的配置和使用較為復雜,初學者在使用的時候容易出現錯誤,希望本文介紹的方法能夠幫助到你。

⑥ windows linux分別使用了哪些訪問控制機制

就windows而言,一個文件會有屬性,對這個文件點右鍵可以看到「屬性」,屬性中可以新建用戶,也可以刪除現有用戶。如果一個文件不能被任何一個用戶使用,也就是說文件的「屬性」不存在任何用戶的時候,這個文件是不能使用的。也就是說,要讓一個文件能夠使用,最少應該給予一個用戶以相應的許可權。還可以設置「共享」,當文件可以被共享的時候,意味著它能夠被任何人訪問到,而這對於一些重要文件來說是相當危險的一件事。還有「存取」、「讀寫」等許可權控制,如果設置得當,打造一個安全性較高的系統還是比較簡單的一件事。更多內容,參見
http://ke..com/view/359977.htm
http://ke..com/view/469056.html?wtp=tt

⑦ liux掃出openssh漏洞怎麼做掃描訪問限制

liux掃出openssh漏洞怎麼做掃描訪問限制的方法:使用chmod更改特定目錄的許可權。這能起到限制特定目錄被某些人訪問的作用,限定某個用戶的目的也能達到,但是會誤傷其他用戶。使用linux容器,例如lxc。耗費空間,設置稍顯麻煩。或者使用setfacl命令設定訪問控制。
(7)linux訪問控制擴展閱讀:
Linux,全稱GNU/Linux,是一種免費使用和自由傳播的類UNIX操作系統,其內核由林納斯·本納第克特·托瓦茲於1991年10月5日首次發布,它主要受到Minix和Unix思想的啟發,是一個基於POSIX的多用戶、多任務、支持多線程和多CPU的操作系統。它能運行主要的Unix工具軟體、應用程序和網路協議。它支持32位和64位硬體。Linux繼承了Unix以網路為核心的設計思想,是一個性能穩定的多用戶網路操作系統。Linux有上百種不同的發行版,如基於社區開發的debian、archlinux,和基於商業開發的Red Hat Enterprise Linux、SUSE、Oracle Linux等。

熱點內容
內置存儲卡可以拆嗎 發布:2025-05-18 04:16:35 瀏覽:330
編譯原理課時設置 發布:2025-05-18 04:13:28 瀏覽:371
linux中進入ip地址伺服器 發布:2025-05-18 04:11:21 瀏覽:606
java用什麼軟體寫 發布:2025-05-18 03:56:19 瀏覽:27
linux配置vim編譯c 發布:2025-05-18 03:55:07 瀏覽:100
砸百鬼腳本 發布:2025-05-18 03:53:34 瀏覽:935
安卓手機如何拍視頻和蘋果一樣 發布:2025-05-18 03:40:47 瀏覽:729
為什麼安卓手機連不上蘋果7熱點 發布:2025-05-18 03:40:13 瀏覽:798
網卡訪問 發布:2025-05-18 03:35:04 瀏覽:505
接收和發送伺服器地址 發布:2025-05-18 03:33:48 瀏覽:367