samba文件共享服务

开通VIP,畅享免费电子书等14项超值服

首页

好书

留言交流

下载APP

联系客服

2019.05.24

文件共享服务---Samba

=============================================================================

★smb:ServiceMessageBlock;服务信息块

★cifs:CommonInternetFileSystem,

★samba:作者:AndrewTridgell;

★功能:

1)程序环境

★samba安装

★主配置文件

★主程序:

★UnitFile

★监听的端口:

★客户端程序:

2)samba的配置

/etc/samba/smb.conf

★主配置文件:/etc/samba/smb.conf

◎全局配置

[global]

share(depricated)匿名共享

server(depricated)实现集中式身份认证

domain

◎共享文件系统:

[shared_ID]

有三类:

常用指令:

2)samba用户管理

★命令:

smbpasswd,pdbedit

1)smbpasswd

语法:

smbpasswd[OPTIONS]USERNAME(系统用户)

选项:

2)pdbedit:

-uUSERNAME:

★访问服务:

☉smbclient交互式客户端程序:

smbclient-LSMB_SERVER[-UUSERNAME]

smbclient//SMB_SERVER[/SHARE_NAME][-UUSERNAME]

☉mount.cifs

注意:

挂载操作中的用户,与-o选项中指定的用户直接产生映射关系;访问挂载,是以-o选项指定的用户身份运行,与本地用户以ID产生映射;

★自定义共享的方式:

comment=

path=

guestok=

readonly=

public=

browseable=

writelist=

☉注意:

定义所有用户在服务级的写权限write=yes(readonly=no)不建议与writelist同时使用;

命令演示:

1.添加用户

[root@centos7~]#pdbedit-a-utao#添加用户newpassword:retypenewpassword:Unixusername:taoNTusername:AccountFlags:[U]UserSID:S-1-5-21-1194301372-4224252613-970535052-1000PrimaryGroupSID:S-1-5-21-1194301372-4224252613-970535052-513FullName:HomeDirectory:\\centos7\taoHomeDirDrive:LogonScript:ProfilePath:\\centos7\tao\profileDomain:CENTOS7Accountdesc:Workstations:Mungeddial:Logontime:0Logofftime:Wed,06Feb203623:06:39CSTKickofftime:Wed,06Feb203623:06:39CSTPasswordlastset:Tue,18Oct201623:24:50CSTPasswordcanchange:Tue,18Oct201623:24:50CSTPasswordmustchange:neverLastbadpassword:0Badpasswordcount:0Logonhours:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF[root@centos7~]#pdbedit-L#列出samba用户tao:1000:[root@centos7~]#pdbedit-a-uxiu#再添加一个用户xiu[root@centos7~]#pdbedit-Ltao:1000:xiu:1001:启动samba服务,并查看端口号

[root@centos7~]#systemctlstartnmb.servicesmb.service[root@centos7~]#ss-unl#查看udp端口137,138StateRecv-QSend-QLocalAddress:PortPeerAddress:PortUNCONN00*:68*:*UNCONN00192.168.1.255:137*:*UNCONN00192.168.1.15:137*:*UNCONN00*:137*:*UNCONN00192.168.1.255:138*:*UNCONN00192.168.1.15:138*:*UNCONN00*:138*:*UNCONN00127.0.0.1:323*:*UNCONN00*:34320*:*UNCONN00:::10025:::*UNCONN00::1:323:::*[root@centos7~]#ss-tnl#查看tcp协议端口139,445StateRecv-QSend-QLocalAddress:PortPeerAddress:PortLISTEN0128127.0.0.1:6012*:*LISTEN050*:445*:*LISTEN050*:3306*:*LISTEN050*:139*:*LISTEN0128*:22*:*LISTEN0128127.0.0.1:631*:*LISTEN0100127.0.0.1:25*:*LISTEN0128127.0.0.1:6010*:*LISTEN0128127.0.0.1:6011*:*LISTEN0128::1:6012:::*LISTEN050:::445:::*LISTEN050:::139:::*LISTEN0128:::22:::*LISTEN0128::1:631:::*LISTEN0100::1:25:::*LISTEN0128::1:6010:::*LISTEN0128::1:6011:::*2.smbclient命令查看目标主机上的共享

这里以centos6主机作为客户端,访问作为samba服务器的centos7

#匿名访问,不输入密码,如下:[root@CentOS6~]#smbclient-L192.168.1.15Enterroot‘spassword:AnonymousloginsuccessfulDomain=[MYGROUP]OS=[Windows6.1]Server=[Samba4.2.3] SharenameTypeComment -------------------- IPC$IPCIPCService(SambaServerVersion4.2.3)AnonymousloginsuccessfulDomain=[MYGROUP]OS=[Windows6.1]Server=[Samba4.2.3] ServerComment ---------------- CENTOS7SambaServerVersion4.2.3 WorkgroupMaster ---------------- MYGROUPCENTOS7 WORKGROUPPC-20160624QLWL #已创建的系统用户来访问,如下:[root@CentOS6~]#smbclient-L192.168.1.15-UtaoEntertao‘spassword:Domain=[MYGROUP]OS=[Windows6.1]Server=[Samba4.2.3] SharenameTypeComment -------------------- IPC$IPCIPCService(SambaServerVersion4.2.3) taoDiskHomeDirectoriesDomain=[MYGROUP]OS=[Windows6.1]Server=[Samba4.2.3] ServerComment ---------------- CENTOS7SambaServerVersion4.2.3 WorkgroupMaster ---------------- MYGROUPCENTOS7 WORKGROUPPC-20160624QLWL3.smbclient命令访问目标主机上的共享服务

#查看系统用户下的共享服务[root@CentOS6~]#smbclient-L192.168.1.15-UtaoEntertao‘spassword:Domain=[MYGROUP]OS=[Windows6.1]Server=[Samba4.2.3] SharenameTypeComment -------------------- appsDisktools IPC$IPCIPCService(SambaServerVersion4.2.3) taoDiskHomeDirectoriesDomain=[MYGROUP]OS=[Windows6.1]Server=[Samba4.2.3] ServerComment ---------------- CENTOS7SambaServerVersion4.2.3 WorkgroupMaster ---------------- MYGROUPCENTOS7 WORKGROUPPC-20160624QLWL访问共享服务

[root@centos7~]#setfacl-mu:tao:rwx/samba/tools#设定tao用户的rwx权限[root@centos7~]#getfacl/samba/toolsgetfacl:Removingleading‘/‘fromabsolutepathnames#file:samba/tools#owner:root#group:rootuser::rwxuser:tao:rwxgroup::r-xmask::rwxother::r-x再次访问上传如下

[root@CentOS6~]#smbclient//192.168.1.15/apps-UtaoEntertao‘spassword:Domain=[MYGROUP]OS=[Windows6.1]Server=[Samba4.2.3]smb:\>ls.D0WedOct1900:31:412016..D0WedOct1900:31:412016 40940blocksofsize1048576.40072blocksavailablesmb:\>lcd/etcsmb:\>putfstabputtingfilefstabas\fstab(99.3kb/s)(average99.3kb/s)#上传成功smb:\>ls.D0WedOct1901:00:432016..D0WedOct1900:31:412016fstabA1017WedOct1901:00:432016 40940blocksofsize1048576.40072blocksavailablesmb:\>rmfstab#删除文件smb:\>ls.D0WedOct1921:12:292016..D0WedOct1900:31:412016 40940blocksofsize1048576.40071blocksavailablesmb:\>5.假设现在tao用户和xiu用户都有写操作,即可以向/samba/tools上传文件,但是我只想允许让tao有上传权限,xiu用户不可以传,该如何设置呢?如下

重启服务,访问如下:

[root@centos7~]#groupadddistro[root@centos7~]#ll-d/samba/tools/drwxrwxr-x+2rootroot30Oct1921:37/samba/tools/[root@centos7~]#chgrpdistro/samba/tools/[root@centos7~]#ll-d/samba/tools/drwxrwxr-x+2rootdistro30Oct1921:37/samba/tools/[root@centos7~]#setfacl-b/samba/tools#为了保证实验,清空目录的acl权限[root@centos7~]#getfacl/samba/toolsgetfacl:Removingleading‘/‘fromabsolutepathnames#file:samba/tools#owner:root#group:distrouser::rwxgroup::r-xother::r-x[root@centos7~]#chmod775/samba/tools/#设定目录的属组有写权限[root@centos7~]#ll-d/samba/tools/drwxrwxr-x2rootdistro30Oct1922:23/samba/tools/[root@centos7~]#usermod-a-Gdistrotao[root@centos7~]#usermod-a-Gdistroxiu[root@centos7~]#idtaouid=1000(tao)gid=1000(tao)groups=1000(tao),2003(distro)[root@centos7~]#idxiuuid=1001(xiu)gid=2002(xiu)groups=2002(xiu),2003(distro)编辑配置文件/etc/samba/smb.conf如下:

[root@CentOS6~]#ll/data/apps/#客户端显示的属主total12-rwxr--r--1100010001017Oct192016fstab-rwxr--r--11001200290Oct192016issue-rw-r--r--11001200213Oct192016test.txt[root@centos7~]#idxiuuid=1001(xiu)gid=2002(xiu)groups=2002(xiu),2003(distro)[root@centos7~]#ll/samba/tools/#服务端显示的属主total12-rwxr--r--1taotao1017Oct1921:37fstab-rwxr--r--1xiuxiu90Oct1922:40issue-rw-r--r--1xiuxiu13Oct1923:33test.txt[root@CentOS6~]#useradd-u1001wang#创建一个同服务端属主id号相同的用户[root@CentOS6~]#su-wang[wang@CentOS6~]$cd/data/apps/[wang@CentOS6apps]$lsfstabissuetest.txt[wang@CentOS6apps]$echonulizaiyiqi>>test.txt#写操作成功[wang@CentOS6apps]$cattest.txttaotaoxiuxiunulizaiyiqi[wang@CentOS6apps]$lltotal12-rwxr--r--1100010001017Oct192016fstab-rwxr--r--1wang200290Oct192016issue-rw-r--r--1wang200225Oct202016test.txt3)smbstatus命令:

演示

[root@centos7~]#smbstatusSambaversion4.2.3PIDUsernameGroupMachineProtocolVersion------------------------------------------------------------------------------2228xiuxiu192.168.1.16(ipv4:192.168.1.16:49088)NT1#挂载访问ServicepidmachineConnectedat-------------------------------------------------------IPC$2228192.168.1.16WedOct1923:57:472016apps2228192.168.1.16WedOct1923:57:472016#客户端方式访问Nolockedfiles

THE END
1.BrowseDefinition&MeaningMerriamThe meaning of BROWSE is to eat (tender shoots, twigs, leaves of trees and shrubs, etc.) : to consume as browse. How to use browse in a sentence.https://www.merriam-webster.com/dictionary/browse
2.allowable(adj.允许的):用来描述那些被系统框架或编程语言明确在软件开发领域,“allowable”(允许的)这一词汇扮演着至关重要的角色,它不仅是定义软件行为、功能和限制的基石,也是确保软件安全性、稳定性和兼容性的关键。作为形容词,“allowable”在软件开发中通常用来描述那些被系统、框架或编程语言明确允许或认可的操作、配置、数据格式等。下面,我们将通过详细的解释和一个形象的https://www.55kaifa.com/ruanjiankaifacihuishuyu/2940.html
3.高中英语人教01阅读理解高频词汇(速记分类版).docx高考英语高频阅读词汇(1) 1. accelerate /?k'sel?re?t/ vt. 加速,促进 2. absolute /'?bs?lu:t/ a/. 绝对的,无条件的;完全的 3. liberal /'l?b?r?l/ a. 慷慨的;丰富的;自由的 4. transport /tr?ns'p?:t/ vt. 运输,运送 n. 运输,运输工具https://www.sfbroad.com/p/206716.html
4.马伍旺3BROSTORE丨中国南京丨或者设计ORDesign案例马伍旺品牌在南京市场一直有良好的客户口杯。继马伍旺川菜、马伍旺饮料厂之后,这一次马伍旺首家3BRO STORE以全新形象,增加咖啡、茶包以及潮流周边,希望为客户提供一个分享新知、松缓身心的城市新聚点。 3 BRO has always enjoyed a strong reputation among customers in the Nanjing market. Following 3 BRO Sichuanhttps://news.znztv.com/bk/136116965.html
5.「显而易见」英语怎么说而Megyn正坐在车上。广播一开始就说了一句:As clear as a bell that Megyn Kelly has gone over to the dark side. 很明显,梅根凯丽已经弃明投暗了。下面我们来解读一下这个词链吧! 今日学习: as clear as a bell as clear as a bell as clear as a bellhttps://mp.weixin.qq.com/s?__biz=MzI4OTAyODUxNA==&mid=2653618214&idx=2&sn=590b45633e1c32e12606ab92de6501da&chksm=f6e1d50f72fff3b42459cfe10140651ddd0b829ec8d9091d529a4635845498d988f41c5c287b&scene=27
6.TOEIC托业词句短语Day02Environment2022-09-06 New words: 1.facilitate facilitative facility 促进 帮助,Schools were located on the same campus tofacilitatethe sharing of resources. 2.failure fail failed fallible 失败 3.figure out,figure out figure out / in charge of / https://www.jianshu.com/p/15391b14b864
7.samba服务的参数public和browseable的区别51CTO博客public=yes 和 browseable=no 通俗的说,就是在配置文件中的共享文件下敲这个命令,只有的通过samba服务共享当前文件不允许可见。其他的非当前共享文件都允许可见。 public=no 和 browseable=yes 通俗的说,就是在配置文件中的共享文件下敲这个命令,只有的通过samba服务共享当前文件允许可见。其他的非当前共享文件都不允许https://blog.51cto.com/13389761/1977823
8.browseable的翻译是:可浏览中文翻译英文意思,翻译英语[translate] acherish; 爱护;[translate] aI know from your telegram that you want to take bunkers 我从您的电报知道您想要采取地堡[translate] aimigrate imigrate[translate] awrite barrier 写障碍[translate] abrowseable browseable[translate]http://eyu.zaixian-fanyi.com/fan_yi_13852508
9.samba参数browseable问题本文探讨了Samba共享目录的配置细节,特别是browseable参数的作用。当browseable设置为no时,即使用户登录成功也无法看到指定的共享文件夹;设置为yes时,则可以正常浏览。该参数控制了共享目录是否在客户端可见。 摘要由CSDN通过智能技术生成 http://zhidao.baidu.com/question/109296371.html https://blog.csdn.net/qk_zhu/archive/2011/04/02/6341221.aspx
10.(转)SAMBA高级配置编辑boss账号的独立配置文件smb.conf.boss,将tech目录里面的browseable = no删除,这样当boss账号访问samba时,tech共享目录对boss账号访问就是可见滴,这样主配置文件smb.conf和boss账号的独立配 置文件相搭配就有实现其他用户访问时tech共享目录是隐藏滴,而boss账号访问时就是可见滴。 http://www.360doc.com/content/16/0906/08/14513665_588730602.shtml
11.BrowseableOnlineBackupSystemdownloadSourceForge.netDownload Browseable Online Backup System for free. Browseable Online Backup System (BOBS) is a complete online backup system. It uses large disks for storing backups and lets users browse and restore the files using a webbrowser.https://sourceforge.net/projects/bobs/
12.Debian9.5系统Samba配置说明pipci说明:browseable用来指定该共享是否在“网上邻居”中可见。 writable = yes/no 说明:writable用来指定该共享路径是否可写。 read only = yes/no 说明:设置共享目录为只读,这个选项和writable是互斥的,最好不要两个同时出现如果同时出现,那么最后出现的那个设置为主要的设置。 https://www.cnblogs.com/pipci/p/10154393.html
13.C++RelativePath类代码示例addBrowseableCode (exporter, compiled, localModuleFolder); }if(exporter.isXcode()) { XCodeProjectExporter& xcodeExporter =dynamic_cast<XCodeProjectExporter&> (exporter);if(project.isAUPluginHost()) xcodeExporter.xcodeFrameworks.addTokens ("AudioUnit CoreAudioKit",false);constStringframeworks(moduleInfohttps://vimsky.com/examples/detail/cpp-ex---RelativePath---class.html
14.LinkedDataLimitations on browseable data So statements which relate things in the two documents must be repeated in each. This clearly is against the first rule of data storage: don't store the same data in two different places: you will have problems keeping it consistent. This is indeed an issue wihttps://www.w3.org/DesignIssues/LinkedData.html
15.TechnicalSEOAudit:EasyGuidetoaComprehensiveAuditReady to find out how to conduct a technical SEO site audit? Here are the steps to follow. 1. Crawl Your Website The first part of the technical SEO audit is making sure your site is crawlable. Website crawling enables search engines to discover and index your website content. When bothttps://neilpatel.com/blog/technical-seo-site-audit/
16.GitHubA Gramps browseable object view. Contribute to cdhorn/CardView development by creating an account on GitHub.https://github.com/cdhorn/CardView
17.[Chapter5]BrowsingandAdvancedDiskSharesYou can restrict a share from being in a browse list by using thebrowseableoption. This boolean option prevents a share from being seen in the Network Neighborhood at all. For example, to prevent the[data]share from the previous chapter from being visible, we could write: https://www.oreilly.com/openbook/samba/book/ch05_01.html
18.LearnhowtosearchfasterwiththePhotoshopDiscoverPanelBrowseable What's New What's New content highlighting new Photoshop features is now browseable through the new What's New section in the Discover panel home.What's New section in Discover panel Browseable What's New in Discover panel https://helpx.adobe.com/photoshop/using/photoshop-discover.html
19.LaunchpadSearch 47,072projects,2,039,039bugs,1,009,596branches,85,858Git repositories,3,147,520translations,817,217answers,76,136blueprints, and counting Launchpad A software collaboration platform that provides Bug tracking One place to track bugs across project boundaries and tools https://launchpad.net/
20.部分配置命令介绍browseable:设置浏览资源时是否显示共享目录,取值范围为“yes”或“no”,若设定为“no”则必须指定共享路径才能存取。 public:设置是否允许匿名访问,取值范围为“yes”或“no”,若设定为“no”则进行身份验证(只有当security = share 时此项才起作用)。 https://zhuanlan.zhihu.com/p/358647923
21.CentOS6.3下Samba服务器的安装与配置腾讯云开发者社区browseable = yes/no 说明:browseable用来指定该共享是否可以浏览。 writable = yes/no 说明:writable用来指定该共享路径是否可写。 available = yes/no 说明:available用来指定该共享资源是否可用。 admin users = 该共享的管理者 说明:admin users用来指定该共享的管理员(对该共享具有完全控制权限)。在samba 3.0中https://cloud.tencent.com/developer/article/1124761
22.smb.conf(5)—Archmanualpages預設設定: browseable = yes browse list (G) 它控制smbd(8)是否執行一個NetServerEnum呼叫來為客戶提供一個瀏覽列表.正常情況它被設為yes.這個選項可能永遠不需要改動. 預設設定: browse list = yes case sensitive (S) 參見NAME MANGLING段的討論. 預設設定: case sensitive = no casesignames (S) 與cahttps://man.archlinux.org/man/smb.conf.5.zh_TW
23.为ASP.NET控件添加设计时支持.NET教程,Asp.Net开发microsoft asp.net 为开发人员提供了一种适用于 web 开发的、功能最为强大的新工具:服务器控件。服务器控件使开发人员能够在短时间内开发出响应速度快而且功能强大的 web 应用程序,所需的时间与在典型的 asp 中创建类似应用程序的时间差不多。 asp.net 服务器控件之所以能够提供生产效率,关键原因之一在于它为 microhttps://www.west.cn/www/info/34310-1.htm
24.Samba服务器配置松篁每一部分的名字和参数都不区分大小写,例如,参数browseable=yes与browseable=YES是完全等价的 2).smb.conf文件的功能 smbd和nmbd这两个守护进程启动时(通常为系统引导时)读配置文件smb.conf,这一配置文件向这两个守护进程说明输出 什么共享、共享输出给谁以及如何进行输出等等。 https://www.iteye.com/blog/shoko-1858710
25.UbuntuManpage:smb.conf注意,自動的宿主目錄共享資源的可瀏覽標誌是從[global]段繼承來的,而不是[homes]段.這樣,當在[homes]段中設置browseable=no時,用戶就看不到單獨的'homes'共享,但可以看到自動的宿主目錄. [printers] 打印機共享設置段 這一段很象[homes]段,不過是用於設置共享打印機的. 如果在本配置文件中存在[printers]段,https://manpages.ubuntu.com/manpages/focal/zh_TW/man5/smb.conf.5.html
26.FREEBSD6.0架设FTP服务器Unix/BSD操作系统家目录预设是该使用者具有读写的权限,所以您无法设定 rw、ro 这二个参数。而且,您也无法设定 path,使用者家目录的所在路径是由系统密码文件中的设定而决定。您只能设定 browseable、disable_ls、disable_modify、及 disable_download。 如果您的 SmbFTPD 支持匿名使用者,匿名使用者 anonymous 及 ftp 会被对映到真实https://www.jb51.net/os/Unix/1487_all.html
27.Chapter2.FastStart:CureforImpatiencebrowseable = No Do not add users to the UNIX/Linux server; all of this will run off the central domain. Configuresmb.confaccording toMember server smb.conf (globals)andMember server smb.conf (shares and services). Join the domain. Note: Do not start Samba until this step has been complehttps://web.mit.edu/samba/swat/help/Samba3-HOWTO/FastStart.html