天天看点

【LinuxService】 SMB and CIFS

# porpose: shareing file system between windows and linux using network

protocol:

smb(service message block): shareing linux file system to windows

cifs(common internet file system): shareing windows file system to linux

software for smb: samba

samba is using 137/udp, 138/udp, 139/tcp, 445/tcp

netbios: windows基于于主机实现互相通信的机制;

15个字符

samba:

nmbd: netbios

smbd: cifs

winbindd: 

unc路径:\\server\shared_name

交互式数据访问:

# smbclient -l host -u username

获取到共享信息之后,

# smbclint //server/shared_name -u username

基于挂载的方式访问:

mount -t cifs //server/shared_name  /mount_point -o username=username,password=password

服务器:

# yum -y install samba

服务脚本:

/etc/rc.d/init.d/nmb

/etc/rc.d/init.d/smb

主配置文件:

/etc/samba/smb.conf

samba用户:

账号:都是系统用户, /etc/passwd

密码:samba服务自有密码文件, 

将系统用户添加为samba的命令:smbpasswd

smbpasswd:

-a sys_user: 添加系统用户为samba用户

-d :禁用

-e: 启用

-x: 删除

配置文件:

smb.conf

全局设定

特定共享的设定

私有家目录

打印机共享

自定义共享

自定义共享:

[shared_name]

path = /path/to/share_directory

comment = comment string

guest ok = {yes|no}

public = {yes|no}

writable = {yes|no}

read only = {yes|no}

write list = +group_name

测试配置文件是否有语法错误,以及显示最终生效的配置:

# testparm

建立samba共享,共享目录为/data,要求:

1)共享名为shared,工作组为magedu;

2)添加组develop,添加用户gentoo,centos和ubuntu,其中gentoo和centos以develop为附加组,ubuntu不属于develop组;密码均为用户名;

3)添加samba用户gentoo,centos和ubuntu,密码均为“mageedu”;

4)此samba共享shared仅允许develop组具有写权限,其他用户只能以只读方式访问;

5)此samba共享服务仅允许来自于172.16.0.0/16网络的主机访问;

继续阅读