参考网址:
http://www.linuxdiyf.com/viewarticle.php?id=56024
http://heylinux.com/archives/874.html
https://jingyan.baidu.com/article/a3aad71ac28786b1fa009675.html
0.samba的安装
(1).检查Samba服务包是否已安装:
(2)Samba至少需要三个文件,分别为:
samba-common-2.2.7a-7.9.0.i386.rpm //服务器和客户端均需要的文件
samba-2.2.7a-7.9.0.i386.rpm //服务器端文件
samba-client-2.27a-7.9.0.i386.rpm //客户端文件
安装上述3个文件.
1.配置
建立建立你要共享文件夹的用户名和密码:
先建立Linux下的用户名和密码——若使用已有的linux用户,此步骤可省略
#useradd -m smb
#passwd smb上述为建立linux用户及密码,会提示你输入用户smb的密码
2.建立和linux里用户对应的 samba用户:
#smbpasswd -a smb提示你输入这个用户的密码
OK
编辑/etc/samba/smb.conf文件:
vi /etc/samba/smb.conf
在最下边建立:
[smb]
comment = share directory
path =/home/smb
writable = yes
read only = on
browsable =yes
valid users = smb
guest ok =on
编辑好这些后不要忘记在文件的最上方有全局区域:
[global]
security = user
4.设置samba自启动
重启smb服务
配置开机自启动
5.在Windows上映射网络驱动盘
Windows 访问 samba 共享连接(假设服务器IP为192.168.10.3)
在[开始]-[运行]中输入 \\192.168.10.3\smb
用户名smb,密码为smbpass命令设置的密码即可
将 samba 共享的 Linux 目录,映射成 Windows 的一个驱动器盘符
在右键点击[我的电脑]-[映射网络驱动器],选择“驱动器”盘符与“文件夹”地址,如 “Z” 与 “\\192.168.10.3\smb”
确认后在“我的电脑”中即可看到新创建的网络驱动器“Z”。
注:
1.无法从win客户机访问SuSE的ftp和samba,可能是防火墙没有关闭……
#systemctl stop firewalld
#systemctl disable firewalld
2.centos下开启samba服务后,在windows下映射网络驱动器,输入用户名和密码后,提示拒绝访问的解决
vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disable 将这个改为disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted