samba服务器的配置如何将共享目录设置为data,共享名为shares?

samba服务器的配置如何将共享目录设置为data,共享名为shares?,第1张

1创建共享目录public,修改权限为777

2创建用户和组,并将用户加为smb账号smbpasswd -a username

3修改主配置文件 vim /etc/samba/smbconf

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

[public]

comment = the share for Alluser

path = /tmp/public //共享目录路径

valid users = @user //能使用该共享资源的用户和组

#read list 只能读取该共享资源的用户和组。

Write list = @user //能读取和写入该共享资源的用户和组

browseable = no //是否列出共享,no即隐藏

4smbclient //ip_addr/public_name -U user_name%passwd //访问共享目录

[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 = 1921681

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 = %mbat

# the login script name depends on theunix user used

; logon script = %ubat

; 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 = wxyz

; wins proxy = yes

; dns proxy = yes

# --------------------------- Printing Options-----------------------------

#

# Load Printers let you load automatically the list of printers rather

# than setting them up individually

#

# 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

以上是smbconf内的配置。

增加用户和组,并设置好用户组的隶属关系。

用smbpasswd -a 增加smb访问密码。

如何在Windows系统和ArchLinux系统之间共享文件?

如何在Windows系统和ArchLinux系统之间共享文件?

在现代计算机环境中,Windows和Linux都是主要的操作系统。然而,Windows和Linux的文件系统和网络协议并不完全相同,这给在两个系统之间共享文件带来了一些挑战。本文将介绍一些实用的技巧和工具,帮助用户在Windows系统和ArchLinux系统之间实现文件共享。

1使用Samba服务器

Samba是一个开源的软件套件,可以在Linux下实现Windows文件共享服务。在ArchLinux中,Samba可以通过pacman包管理器安装:

`

sudopacman-Ssamba

`

安装完后,可以使用以下命令启动Samba服务:

`

sudosystemctlstartsmbservice

sudosystemctlstartnmbservice

`

这将启动Samba服务器,并允许用户通过Windows网络访问Linux共享文件夹。

2使用SSH协议

SSH(SecureShell)是一个加密协议,它可以安全地传输文件和执行远程命令。为了在Windows和Linux之间共享文件,用户可以在两个系统之间建立SSH连接,并使用SCP(SSHCopy)命令复制文件。在Windows中,用户可以使用PuTTY等SSH客户端,连接到Linux服务器并使用SCP命令复制文件。在Linux中,用户可以使用OpenSSH服务器提供SSH服务,并使用SCP命令将文件复制到Windows电脑上。

3使用FTP协议

FTP(FileTransferProtocol)是另一种在Windows和Linux之间传输文件的常用协议。在实现FTP协议之前,用户需要在ArchLinux系统上安装FTP服务器。在ArchLinux中,ProFTPD是一个常见的FTP服务器,可以通过以下命令安装:

`

sudopacman-Sproftpd

`

安装好ProFTPD之后,可以通过以下命令启动FTP服务器:

`

sudosystemctlstartproftpdservice

`

通过FTP客户端连接到Linux服务器,然后可以在Linux和Windows之间传输文件。

4使用NFS协议

NFS(NetworkFileSystem)是一种Linux的文件共享协议,它可以在Linux系统之间方便地共享文件。要在ArchLinux中设置NFS服务器,用户需要安装nfs-utils和nfs-server软件包:

`

sudopacman-Snfs-utilsnfs-server

`

安装好软件包后,用户需要配置NFS服务器的共享目录和权限:

`

sudomkdir/mnt/nfs

sudochownnobody:nobody/mnt/nfs

sudochmod777/mnt/nfs

`

在Windows计算机上,用户可以使用NFS客户端连接到ArchLinux服务器并访问共享文件夹。用户可以使用IP地址或主机名连接到NFS服务器,例如:

`

\\1921681100\mnt\nfs

`

需要注意的是,在使用NFS协议时,用户应该保护好共享文件夹的安全性,并且只允许授权用户访问文件夹。

结论:

在Windows系统和ArchLinux系统之间共享文件是一项非常实用而又必要的技能。用户可以选择适合自己的文件共享协议和工具,以实现文件传输和共享。无论是通过NFS协议,还是使用Samba和FTP协议,用户都应该保护好共享文件夹的安全性,并谨慎地授权权限,以保证文件的机密性和完整性。

这里以windows系统和linux系统为例,简单介绍一下如何在这2种系统下搭建ftp服务器,整个过程非常简单,感兴趣的朋友可以自己尝试一下:

windows

windows系统自带有ftp服务器,只需要在控制面板的“程序和功能”模块中开启一下就行,下面我简单介绍一下操作过程:

1首先,打开控制面板,依次点击“程序”->“启用或关闭windows功能”,在弹出的windows功能窗口中勾选“ftp服务器”和“iis管理控制台”,如下,等待程序安装完成:

2接着在搜索栏打开“iis控制器”,右键左侧的“网站”条目,在弹出的功能列表中选择“添加ftp站点”,这时我们就可以直接设置ftp服务器根目录了(也就是需要共享的文件夹),如下:

3然后就是设置ftp服务器ip地址和端口号,这里可以设置为内网ip,也可以设置为外网ip,根据自己需求设置就行,如下:

4接着就是设置访问用户及读写权限,这里可以是匿名用户、指定用户、所有用户、用户组等,如下:

5最后设置完成后,在浏览器输入“ftp://ftp服务器ip地址”就可以直接访问ftp服务器了,如下,所有文件都已列出,可以直接进行下载:

linux

这里需要先安装vsftp这个工具包,然后启动ftp服务,之后就可以直接访问ftp服务器上的文件了,下面我简单介绍一下操作过程:

1首先,安装vsftpd工具包,这个直接在终端输入命令“yuminstall-yvsftpd”就行,或者(“aptinstall-yvsftpd”),如下:

2安装完成后,这里你可以对/etc/vsftpd/vsftpdconf文件进行进行简单配置,设置用户访问策略等,官方文档有详细说明,修改对应参数就行,如下:

3接着就是启动ftp服务,直接运行“systemctlstartvsftpd”命令(或者“servicevsftpdstart”命令)就行,如下,ftp服务已经正常运行:

4最后就可以直接使用sftp或者ftp命令连接ftp服务器了,效果如下,输入用户password,成功验证后就可以直接上传下载文件了:

至此,我们就完成了在windows系统和linux系统下搭建ftp服务器。总的来说,整个过程非常简单,只要你熟悉一下上面的操作过程,很快就能掌握的,当然,你也可以借助现有的ftp软件来搭建ftp服务器,都行,网上也有相关教程和资料,介绍的非常详细,感兴趣的话,可以搜一下,希望以上分享的内容能对你有所帮助吧,也欢迎大家评论、留言进行补充。

groupadd salers

groupadd managers

建立用户 useradd -G salers -N mary

再把mary加入经理组 usermod -a -G mary managers

建立 salers 文件夹 mkdir -p /share/sale_data

改变用户 chown mary /share/sale_data

改变组 chgrp salers /share/sale_data

改变权限 chmod 2755 /share/sale_data

增加samba 用户 smbpasswd -a mary

chkconfig --level 35 smb on

# smbconf

[sale]

comment = SalesDirectories

path = /share/sale_data

public = yes

read=@sale

write list = mary

#改变权限 chmod 555 /share/public_data

[public]

comment = Public Directories

path = /share/public_data

public = yes

DABAN RP主题是一个优秀的主题,极致后台体验,无插件,集成会员系统
网站模板库 » samba服务器的配置如何将共享目录设置为data,共享名为shares?

0条评论

发表评论

提供最优质的资源集合

立即查看 了解详情