作为服务器端实现:
smb:service message block ----progress:smbd port:445/tcp
netbios:本地名称解析 --------progress:nmbd port:137/udp 138/udp 139/tcp
安装:
[root@sherry /]# yum install samba -y
启动:
[root@sherry /]# /etc/init.d/smb start
Starting SMB services: [ OK ]
[root@sherry /]# /etc/init.d/nmb start
Starting NMB services: [ OK ]
Windows查看:
配置文件:
[root@sherry /]# cd /etc/samba/
[root@sherry samba]# ls
lmhosts smb.conf smbusers
Samba的用户:
1.系统用户
2.密码是独立的,非为/etc/shadow中的密码
设置密码 smbpasswd -a username
[root@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
设置用户密码:(尽量于操作系统不一致)
[root@sherry ~]# smbpasswd -a samba
New SMB password:
Retype new SMB password:
Added user samba.
[root@sherry home]# cd samba/
[root@sherry samba]# ls
[root@sherry samba]# touch a
[root@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
以上默认访问家目录
配置文件解释:
[root@sherry samba]# cp smb.conf{,.bak}
[root@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有一个即可