1 samba服务搭建环境
server端:
CentOS release 6.8 (Final)
ip 192.168.91.3
hostname:Darren
client端:
windows 7
2 server端安装smbd服务
[root@Darren ~]# yum -y install samba
[root@Darren vsftpd]# rpm -qa |grep samba
samba-winbind-clients-3.6.23-36.el6_8.x86_64
samba-3.6.23-36.el6_8.x86_64
samba-client-3.6.23-36.el6_8.x86_64
samba-winbind-3.6.23-36.el6_8.x86_64
samba-common-3.6.23-36.el6_8.x86_64
[root@Darren init.d]# /etc/init.d/smb restart
[root@Darren init.d]# netstat -nltup|grep smbd
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 33185/smbd
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 33185/smbd
tcp 0 0 :::445 :::* LISTEN 33185/smbd
tcp 0 0 :::139 :::* LISTEN 33185/smbd
[root@Darren init.d]# ps -ef|grep smbd
root 33185 1 0 21:41 ? 00:00:00 smbd -D
root 33187 33185 0 21:41 ? 00:00:00 smbd -D
root 33251 26115 0 21:43 pts/0 00:00:00 grep smbd
[root@Darren init.d]# chkconfig --level 2345 smb on
3 设置samba主要配置文件
(1)访问方式为share
配置文件添加如下:
[root@Darren samba]# vim /etc/samba/smb.conf
[global]
security = share -- 访问的方式,share不需要密码,user需要用户名和密码
[public]
comment = Public Stuff
path = /home/samba
writeable = yes
write list = +staff
read only = No
guest ok = Yes
创建共享文件
[root@Darren samba]# mkdir /home/samba^C
测试:在windows文件夹中输入
\\192.168.91.3\
可以看到public文件夹
(2)访问方式为user
[root@Darren samba]# vim /etc/samba/smb.conf
[global]
security = user
[public]
comment = Public Stuff
path = /home/samba
writeable = yes
write list = +staff
read only = No
guest ok = Yes
#把用户user3添加到samba中,并设置访问密码,这个密码和user3在linux用户中密码可以不一样
[root@Darren samba]# smbpasswd -a user3
New SMB password:
Retype new SMB password:
Added user user3.
#重启smb服务:
[root@Darren samba]# /etc/init.d/smb restart
测试在windows文件夹中输入
\\192.168.91.3\
输入用户user3和密码即可访问共享文件夹,除了可以看到public文件夹外,默认还会看到user3文件夹(指向linux中user3用户的家目录)