内容简介:##原理windows 和samba服务进行通信使用的是NETBIOS协议linux和linux 之间通信使用的是SMB协议
iptables -A INPUT -p tcp -m multiport --dport 139,445 -j ACCEPT
##原理
windows 和samba服务进行通信使用的是NETBIOS协议
linux和 linux 之间通信使用的是SMB协议
配置文件
[root@server samba]# cat 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 = myshare security = user map to guest = bad user passdb backend = tdbsam printing = cups printcap name = cups load printers = yes cups options = raw [homes] comment = Home Directories valid users = %S, %D%w%S browseable = No read only = No inherit acls = Yes [printers] comment = All Printers path = /var/tmp printable = Yes create mask = 0600 browseable = No [print$] comment = Printer Drivers path = /var/lib/samba/drivers write list = root create mask = 0664 directory mask = 0775 [share] path=/smbshare public=yes writable=yes [share1] path=/smbu valid users = smbuser1,smbuser2,@g1 writable=yes
配置匿名访问配置
[global] workgroup = myshare security = user map to guest = bad user # 添加此行 passdb backend = tdbsam printing = cups printcap name = cups load printers = yes cups options = raw
末尾曾加
[share] path = /smbshare public = yes writable=yes
重启
[root@localhost ~]# systemctl enable smb nmb # smb是Linux和Linux之间的协议,nmb是Linux和Windows之间的协议 Created symlink from /etc/systemd/system/multi-user.target.wants/smb.service to /usr/lib/systemd/system/smb.service. Created symlink from /etc/systemd/system/multi-user.target.wants/nmb.service to /usr/lib/systemd/system/nmb.service. [root@localhost ~]# systemctl restart smb nmb
后面连接出错,请先关selinux 然后重启服务
客户端连接
[root@node-server-1 ~]# mount -t cifs //192.168.50.156/public /media/ mount: wrong fs type, bad option, bad superblock on //192.168.50.156/public, missing codepage or helper program, or other error (for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount.<type> helper program) In some cases useful info is found in syslog - try dmesg | tail or so.
需要安装
yum -y install cifs-utils
windows连接
然后再次连接
[root@desktop ~]# mount -t cifs //172.10.100.128/share /media/ Password for root@//172.10.100.128/share: [root@desktop ~]# cd /media/ [root@desktop media]# ls ls: reading directory .: Permission denied [root@desktop media]#
添加用户
1.创建samba用户
[root@server samba]# useradd -s /sbin/nologin smbuser1 [root@server samba]# smbpasswd -a smbuser1 New SMB password: Retype new SMB password: Added user smbuser1.
配置文件假如 smbuser1
[share1] path=/smbu valid users = smbuser1 writable=yes
挂载
mount -t cifs //172.10.100.128/share1 -o username=smbuser1 /mnt/u1/
设置开机启动
[root@desktop mnt]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Sat May 6 22:20:05 2017 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/cl-root / xfs defaults 0 0 UUID=8567c1db-cc09-442e-83ce-cfcdd1f8f0df /boot xfs defaults 0 0 /dev/mapper/cl-swap swap swap defaults 0 0 //172.10.100.128/share1 /mnt/u4 cifs defaults, username=smbuser1,password=123456 0 0
多用户设置
1.创建多个 Samba 用户
[root@server samba]# useradd -s /sbin/nologin smbuser2 [root@server samba]# smbpasswd -a smbuser2 New SMB password: Retype new SMB password: Added user smbuser2. [root@server samba]# groupadd g1 [root@server samba]# useradd -s /sbin/nologin -g g1 smbu3 [root@server samba]# smbpasswd -a smbu3 New SMB password: Retype new SMB password: Added user smbu3.
2.配置文件修改为
[share1] path=/smbu valid users = smbuser1,smbuser2,@g1 //多个用户用,隔开,@代表组,这里表示组1 writable=yes
3.客户端挂载
mount -t cifs //172.10.100.128/share1 -o username=smbuser1 /mnt/u1/ mount -t cifs //172.10.100.128/share1 -o username=smbuser2 /mnt/u2/ mount -t cifs //172.10.100.128/share1 -o username=smbu3 /mnt/u3/
4.配置文件多个用户共享
[root@desktop samba]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Sat May 6 22:20:05 2017 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/cl-root / xfs defaults 0 0 UUID=8567c1db-cc09-442e-83ce-cfcdd1f8f0df /boot xfs defaults 0 0 /dev/mapper/cl-swap swap swap defaults 0 0 //172.10.100.128/share1 /mnt/u4 cifs defaults,credentials=/smb.mount 0 0
创建一个文件
[root@desktop samba]# cat /smb.mount username=smbuser1 password=123456 username=smbuser2 password=123456
挂载
[root@desktop samba]# mount -a [root@desktop samba]# mount | tail -1 //172.10.100.128/share1 on /mnt/u4 type cifs (rw,relatime,vers=1.0,cache=strict,username=smbuser2,domain=SERVER,uid=0,noforceuid,gid=0,noforcegid,addr=172.10.100.128,unix,posixpaths,serverino,mapposix,acl,rsize=1048576,wsize=65536,echo_interval=60,actimeo=1)
故障处理
1.报错 Unable to find suitable address.
[root@client mnt]# mount -t cifs -o username=smb1 //172.10.100.129/share /mnt Password for smb1@//172.10.100.129/share: ****** Unable to find suitable address.
检查防火墙
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- 6、如何获取配置中心的配置
- React降级配置及Ant Design配置
- vscode 配置eslint 开发vue的相关配置
- git commit 规范校验配置和版本发布配置
- hadoop地址配置、内存配置、守护进程设置、环境设置
- 在hibernate中配置事务级别与命名查询配置【原创】
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
JavaScript语言精髓与编程实践
周爱民 / 电子工业出版社 / 2012-3 / 79.00元
《JavaScript语言精髓与编程实践(第2版)》详细讲述JavaScript作为一种混合式语言的各方面特性,包括过程式、面向对象、函数式和动态语言特性等,在动态函数式语言特性方面有着尤为细致的讲述。《JavaScript语言精髓与编程实践(第2版)》的主要努力之一,就是分解出这些语言原子,并重现将它们混合在一起的过程与方法。通过从复杂性到单一语言特性的还原过程,读者可了解到语言的本质,以及“层......一起来看看 《JavaScript语言精髓与编程实践》 这本书的介绍吧!