- 论坛徽章:
- 0
|
匿名用户与普通用户并发登录samba服务器
需要实现功能
* 一个文件服务器通过\\ip或者\\name访问,不输入密码即能查看到根下的目录;
* 要匿名找文件的直接点进去各个目录里面拷贝文件,不能删除;
*单个目录由单个帐号在多台计算机上进行内容维护,即可以删除修改新建之类,这些帐号由密码保护。
*有多台电脑使用同一个帐号要往共享目录里面写东西,这几个电脑的操作员都不希望自己知道这个密码。
测试实现过程
首先考虑使用 security = share 这种方式,经测试,此方式可以较好实现匿名访问只读,但是涉及到写操作就出现无法与授权用户区分的问题。具体如下:
writeable (S)
Inverted synonym for read only.
read only (S)
An inverted synonym is writeable.
If this parameter is yes, then users of a service may not create or modify files in the service
directory.
Note that a printable service (printable = yes) will ALWAYS allow writing to the directory (user
privileges permitting), but only via spooling operations.
Default: read only = yes
write list (S)
This is a list of users that are given read-write access to a service. If the connecting user is in
this list then they will be given write access, no matter what the read only option is set to. The
list can include group names using the @group syntax.
Note that if a user is in both the read list and the write list then they will be given write
access.
By design, this parameter will not work with the security = share in Samba 3.0.
Default: write list =
Example: write list = admin, root, @staff
“By design, this parameter will not work with the security = share in Samba 3.0.” 意味着 security = share 这种方式的 write list 参数不可用,即 security = share 无法满足需求。
只能使用 security = user 进行尝试。
匿名用户与普通用户并发登录samba服务器--ZT公社古公的samba力作
6楼实现的原理是先匿名访问文件共享服务器,需要获取目录写权限时,首先访问一下需要权限的某个目录如HOME,登陆了之后Windows系统就缓存了用户名和密码,这样再访问需要写的目录时就自动有用户名和密码进行了验证(系统并无任何提示),这样就从HOME目录登陆过程中继承了用户登录信息进而获得了权限。
从chinaunix帖子中可以总结出如下解决方法:
1. 使用 map to guest = bad user 来实现匿名访问文件服务器根目录列表,以避免访问服务器即需要输入用户和密码的问题;
2. 共享资源使用普通最小配置 guest ok = yes 及 write list 参数即可,需要注意目录权限及属主问题;
3. 配合Windows系统NET USE命令进行共享资源映射到盘符,使写权限的计算机不知道密码也可以正常操作该共享目录;
具体配置过程
[root@mail samba]# mkdir /data
[root@mail samba]# mkdir /data/lab
[root@mail samba]# adduser lab
[root@mail samba]# chown lab.lab /data/lab/
[root@mail samba]# smbpasswd -a lab
New SMB password:
Retype new SMB password:
Added user lab.
smb.conf配置文件
security = user
map to guest = Bad User
[lab]
comment = Lab Share
path = /data/lab
guest ok = yes
write list = lab
需要向里面写数据的三台机器使用命令一次设置映射网络驱动器,只要不主动断开这个映射,以后一直都可以使用,/PERSISTENT:YES 参数表示记忆密码映射状态为永久。
命令如下:
net use x: \\file_server\lab password /user:lab /PERSISTENT:YES
如有必要可能需要删除现有连接参数及密码:
net use * /delete
该共享的管理员可以将映射命令做成BAT文件,存在U盘上或者是直接发给需要设置写权限的计算机上运行。
如果此目录的管理员需要在某个机器上临时写几个文件进去,只需要浏览进HOME,登录后再访问lab共享,就可以写文件了。 |
|