当前位置:首页 » 密码管理 » 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等。

热点内容
kotlinandroid 发布:2025-05-17 23:19:09 浏览:974
云编程英语 发布:2025-05-17 23:18:34 浏览:623
androidstudio导入类 发布:2025-05-17 23:15:36 浏览:236
私人电脑服务器如何设置 发布:2025-05-17 23:14:48 浏览:366
安卓手机微信老是闪退是什么原因 发布:2025-05-17 23:07:50 浏览:267
电脑服务器电源好还是普通电源好 发布:2025-05-17 22:53:53 浏览:21
消防防诈骗脚本 发布:2025-05-17 22:49:31 浏览:878
凯酷2021选哪个配置 发布:2025-05-17 22:46:06 浏览:660
苹果好用的解压软件 发布:2025-05-17 22:42:23 浏览:382
我的世界服务器莫名崩溃 发布:2025-05-17 22:40:57 浏览:478