设为首页 收藏本站
查看: 671|回复: 0

[经验分享] samba服务配置详解

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-5-30 09:24:31 | 显示全部楼层 |阅读模式
作为服务器端实现:
smb:service message block     ----progress:smbd   port:445/tcp
netbios:本地名称解析  --------progress:nmbd  port:137/udp 138/udp 139/tcp
安装:
1
[iyunv@sherry /]# yum install samba -y



启动:
1
2
3
4
[iyunv@sherry /]# /etc/init.d/smb start
Starting SMB services:                                     [  OK  ]
[iyunv@sherry /]# /etc/init.d/nmb start
Starting NMB services:                                     [  OK  ]



windows查看: wKioL1dHymLAcNDdAADEZutqikE849.jpg
配置文件:
1
2
3
[iyunv@sherry /]# cd /etc/samba/
[iyunv@sherry samba]# ls
lmhosts  smb.conf  smbusers



1
2
3
4
samba的用户:
     1.系统用户
     2.密码是独立的,非为/etc/shadow中的密码
    设置密码 smbpasswd -a username



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[iyunv@sherry ~]# smbpasswd  -help
When run by root:
    smbpasswd [options] [username]
otherwise:
    smbpasswd [options]

options:
  -L                   local mode (must be first option)
  -h                   print this usage message
  -s                   use stdin for password prompt
  -c smb.conf file     Use the given path to the smb.conf file
  -D LEVEL             debug level
  -r MACHINE           remote machine
  -U USER              remote username
extra options when run by root or in local mode:
  -a                   add user
  -d                   disable user
  -e                   enable user
  -i                   interdomain trust account
  -m                   machine trust account
  -n                   set no password
  -W                   use stdin ldap admin password
  -w PASSWORD          ldap admin password
  -x                   delete user
  -R ORDER             name resolve order



设置用户密码:(尽量于操作系统不一致)
1
2
3
4
[iyunv@sherry ~]# smbpasswd -a samba
New SMB password:
Retype new SMB password:
Added user samba.



1
2
3
[iyunv@sherry home]# cd samba/
[iyunv@sherry samba]# ls
[iyunv@sherry samba]# touch a



wKioL1dHyr6he8y5AAEr3W-Iyto568.jpg
1
2
3
4
[iyunv@sherry samba]# ll
total 4
-rw-r--r-- 1 root  root   0 May 27 10:12 a
-rwxr--r-- 1 samba sherry 3 May 27 10:13 b.txt



以上默认访问家目录

配置文件解释:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
[iyunv@sherry samba]# cp smb.conf{,.bak}
[iyunv@sherry samba]# vim smb.conf
[global]
        workgroup = WORKGROUP
        server string = Samba Server Version %v
        netbios name = sherry   #windows上显示的主机名称  会转为大写
;       interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24     # 监听接口  ip  网卡 网络
;       hosts allow = 127. 192.168.12. 192.168.13. #监听主机
       log file = /var/log/samba/log.%m  #日志 %m变量替换  用户名
       max log size = 50   #每个日志50kb  超过则滚动日志
        security = user  #user根据用户   share匿名  server账号密码集中管理 后两项deprecated
        passdb backend = tdbsam  #密码保存方式
        load printers = yes  #打印机
        cups options = raw   #通用raw模式


[homes]
        comment = Home Directories
        browseable = no
        writable = no     #家目录不让写
;       valid users = %S
;       valid users = MYDOMAIN\%S

# 定义一个共享目录
[node1]
        comment=shared node1
        path=/sambashared/node1   #登入用户对此目录要有操作权限
        writable = yes           #所有用户进程写权限
;       write list = samba ,user2   #进程能写白名单  与上述不要一起开启  用@groupname   +groupname  设置组
;       browseable = no  #不在白名单中的用户对此目录是否能够显示
;       guest ok = yes   #不在白名单中的用户是否能够访问
;       read only=yes #只读
;       writable=no#是否能写 与read only有一个即可



配置文件定义一个共享目录:
1
2
3
4
5
[node1]
        comment=shared node1
        path=/sambashared/node1
        writable = yes
        write list = samba



测试配置文件语法,并显示最终配置:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
[iyunv@sherry node1]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[node1]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions

[global]
    server string = Samba Server Version %v
    log file = /var/log/samba/log.%m
    max log size = 50
    client signing = required
    idmap config * : backend = tdb
    cups options = raw

[homes]
    comment = Home Directories
    browseable = No

[printers]
    comment = All Printers
    path = /var/spool/samba
    printable = Yes
    print ok = Yes
    browseable = No

[node1]
    comment = shared node1
    path = /sambashared/node1
    write list = samba
    read only = No




linux client:
1
[iyunv@marvin node1]# yum -y install samba-client



登入
1
2
3
4
5
6
7
[iyunv@marvin node1]# smbclient  //sherry/node1 -U samba
Enter samba's password:
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.23-35.el6_8]
smb: \> put anaconda-ks.cfg
putting file anaconda-ks.cfg as \anaconda-ks.cfg (249.4 kb/s) (average 249.4 kb/s)
smb: \> get a
getting file \a of size 0 as a (0.0 KiloBytes/sec) (average 0.0 KiloBytes/sec)



服务器:
1
2
3
4
[iyunv@sherry node1]# ll
total 4
-rw-r--r-- 1 root  root      0 May 27 11:33 a
-rwxr--r-- 1 samba sherry 1277 May 27 11:38 anaconda-ks.cfg



客户端 挂载到本地:
1
[iyunv@marvin samba]# yum install cifs-utils -y



1
2
3
4
5
6
7
[iyunv@marvin samba]# mount -t cifs //sherry/node1 /mnt/samba/node1/ -o username=samba   # username=samba,passwd=222222
Password:

[iyunv@marvin node1]# df -h
Filesystem               Size  Used Avail Use% Mounted on
.......
//sherry/node1          1004M   18M  936M   2% /mnt/samba/node1



over

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-223719-1-1.html 上篇帖子: CentOS 7 用通用二进制的格式安装方法总结 下篇帖子: CentOS6安装DNSmasq
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表