02-Samba配置

1.检查samba软件包
# rpm -qa | grep samba

2.安装samba软件包
# yum -y install samba

3.修改配置文件(匿名访问)
# vim /etc/samba/smb.conf
security = share (Windows访问必须)

[dir]
path = /smbshare
guest ok = yes 或 public = yes
writable = yes

4.启动服务
# service nmb restart

# /etc/init.d/nmb restart

#service smb restart

# /etc/init.d/smb restart

5.开机自动启动服务
# chkconfig nmb on

# chkconfig smb on

5.1.查看服务端口
# netstat -tunlp | grep :137
# netstat -tunlp | grep :138
# netstat -tunlp | grep :139
# netstat -tunlp | grep :445

6.客户端查看共享
# smbclient -L //192.168.6.11

7.客户端访问共享
# smbclient //192.168.6.11/dir
help 帮助
ls 查看
put 上传
get 下载
lcd 切换本地路径
quit 退出

8.注意
(1)能读就能下载
(2)能写就能上传
需要共享写权限和文件系统写权限
(3)非匿名访问设置
# vim /etc/samba/smb.conf
security = user
[dir]
path = /smbshare
writable = yes

# smbpasswd -a haoge
# pdbedit -L

# smbclient //192.168.6.11/dir -U haoge

(4)配置多用户不同权限
# vim /etc/samba/smb.conf
security = user
[dir]
path = /smbshare
#定义可访问共享的用户和组
valid users = haoge @group1
#定义具有写权限的用户和组,未定义则为只读
write list = haoge

(5)配置隐藏共享
#定义隐藏共享,默认为非隐藏。yes为可见,no为隐藏
browseable = no

(6)配置白名单
host allow = 127. 192.168.6.

(7)客户端通过挂载方式访问共享
# mkdir /smbdir
# mount -t cifs -o user=haoge,pass=123 //192.168.6.11/dir /smbdir
# df -Th
# cd /smbdir && ll

(8)开机自动挂载samba共享
# vim /etc/fstab
//192.168.6.11/dir /smbdir cifs user=haoge,pass=123 0 0
# mount -a
# cd /smbdir && ll

(9)按需挂载
服务器端设置
# mkdir -p /smbmount/autosmb
# vim /etc/samba/smb.conf
[autosmb]
path = /smbmount/autosmb
valid users = haoge @root
write list = haoge @root
# chmod -R 1777 /smbmount/
客户端设置
# vim /etc/auto.master
/smbmount /etc/auto.misc
# vim /etc/auto.misc
autosmb -fstype=cifs,user=haoge,pass=123 ://192.168.6.11/autosmb
# service autofs restart
# cd /smbmount/autosmb && ll
# df -Th

 

 

posted @ 2018-02-26 21:32  freecd.cn  阅读(82)  评论(0编辑  收藏  举报