centos7 安装samba服务
samba-安装
1. samba-安装
-
安装sabma服务
[root@node02 ~]# yum install samba samba-client samba-swat -y
-
启动服务
[root@node02 ~]# systemctl enable smb [root@node02 ~]# systemctl enable nmb [root@node02 ~]# systemctl start smb [root@node02 ~]# systemctl start nmb
2. 安装samba使用密码用户连接
-
创建部门用户
[root@node02 ~]# useradd web
-
创建用户密码
[root@node02 ~]# smbpasswd -a web New SMB password: Retype new SMB password: Added user web. # 注释: 这里密码我设置的web@963852#@! 根据自己情况配置密码
-
创建需要共享的挂载目录
[root@node02 ~]# mkdir -p /smb/web [root@node02 ~]# mkdir -p /sma/public [root@node02 ~]# chmod 777 /smb/web/ [root@node02 ~]# chmod 777 /sma/public/
-
配置samba配置文件
[root@node02 ~]# cat /etc/samba/smb.conf # See smb.conf.example for a more detailed config file or # read the smb.conf manpage. # Run 'testparm' to verify the config is correct after # you modified it. [global] workgroup = SAMBA security = user passdb backend = tdbsam printing = cups printcap name = cups load printers = yes cups options = raw # 新添加web共享存储配置 [WEB] comment = WEB path = /smb/web public = yes valid users = web # 用该部门的用户才能有权限 security = share guest ok = yes writeable = yes # 公共文件夹,该目录所有有密码的用户均有权限 [Public] comment = Public path = /sma/public public = yes writeable = yes
-
重启服务
[root@node02 ~]# systemctl restart smb [root@node02 ~]# systemctl restart nmb
-
连接服务测试
输入用户和密码就可以,访问了
3. 安装samba使用无密码连接
-
配置sma.conf文件
若要设置无密码登录,可如下设置
[root@node02 ~]# vim /etc/samba/smb.conf [root@node02 ~]# cat /etc/samba/smb.conf # See smb.conf.example for a more detailed config file or # read the smb.conf manpage. # Run 'testparm' to verify the config is correct after # you modified it. [global] workgroup = root security = user map to guest = Bad User #旧版本security = share 即可无密码,新版本security = user且 map to guest = Bad User 才行 # 公共文件夹,该目录所有有密码的用户均有权限 [Public] comment = Public path = /sma/public public = yes writeable = yes
-
重启服务就行
[root@node02 ~]# systemctl restart smb [root@node02 ~]# systemctl restart nmb
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?