内容简介:##原理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.
检查防火墙
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Head First EJB(中文版)
KathySierra,Ber / 中国电力出版社 / 2006-9 / 79.00元
有些人只是想通过认证来取悦挑剔的老板,但相信你不是这种人。确实,你也想通过Su n认证业务组件开发人员(SCBCD)考试,但不仅如此,你还需要真正把EJB用到实处。你要构建应用,要对付最后期限,如果通过考试之后第二天早上就把你学过的EJB知识忘得一干二净,你肯定会受不了。 我们会看着你稳稳当当地通过考试,而且会帮你在实际中使用EJB。你会深入地了解EJB体系结构、会话、实体和消息驱动......一起来看看 《Head First EJB(中文版)》 这本书的介绍吧!