21 Samba配置详解

1、SMB介绍

Samba可以实现Linux和Windows的文件共享     


SMB(Service Message Block)涉及的端口

smb:tcp 139 445

nmbd udp 137 138


samba用户是系统用户但密码是独立的,非/etc/shadow中的密码,使用smbpasswd设置访问smb的密码。


sambclient -L Server -U username检查服务器上的共享

smbclient //Server/Shared -U username以交互式模式连入服务器的某共享


smb配置文件/etc/samba/smb.conf常用选项

[global]

interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24 指定监听的IP、端口

hosts allow = 127. 192.168.12. 192.168.13.指定可以访问SMB的IP


[public]

comment = Public Stuff                         共享的备注信息

path = /home/samba         指定共享的目录

write list = +staff                 指定只有staff组中的用户有写权限

create mask = 0644                                                                修改文件权限


testparm测试配置文件语法错误,并显示最终生效的配置

     


linux挂载cifs文件系统

mount -t cifs //Server/Shared /path/to/mount_point -o username=smbuser



2、SMB安装配置

共享名为myshared,仅mygroup组中的用户具有执行权限,所有文件不具有执行权限,不可删除他人上传的文件


yum -y install samba samba-client


[root@localhost ~]# testparm

Load smb config files from /etc/samba/smb.conf

rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)

Processing section "[myshared]"

Loaded services file OK.

Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions


[global]

        workgroup = MYGROUP

        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


[myshared]

        comment = myshared

        path = /myshared

        write list = +mygroup

        create mask = 0644

[root@localhost ~]# 


groupadd mygroup

useradd -m userrw

useradd -m userro

usermod -a -G mygroup userrw

smbpasswd -a userrw

smbpasswd -a userro


mkdir /myshared

chown root:mygroup /myshared

chmod +t /myshared

chmod g+w /myshared


service smb start

service nmb start

chkconfig smb on

chkconfig nmb on





猜你喜欢

转载自blog.51cto.com/kaiyuandiantang/2299975
21
21)