收藏 分销(赏)

如何在samba服务器上添加用户(修正版).doc

上传人:pc****0 文档编号:9010422 上传时间:2025-03-11 格式:DOC 页数:4 大小:43.50KB
下载 相关 举报
如何在samba服务器上添加用户(修正版).doc_第1页
第1页 / 共4页
如何在samba服务器上添加用户(修正版).doc_第2页
第2页 / 共4页
点击查看更多>>
资源描述
如何在samba服务器上添加用户(修正版) 一、samba用户一般添加访求 一般的,你要先加个用户名,再设置密码。 添加用户的命名如下: sudo useradd 要新添加的用户名 说明:useradd与adduser都表示添加系统用户,但两者有一个不同,使用useradd添加系统用户时,只添加了用户名,系统不会询问你输入该用户的其它信息包括密码,由于没有提示设置密码,该用户是不能用于本地登录的,若要用该用户登录本地系统,必须再使用passwd命令为其设置一个密码;相反的,使用adduser添加系统用户时,会提示输入密码等用户信息。 由于上述命令只是添加了一个没有密码的系统用户,所以既不能用来登录本地系统,也不能用作samba用户。若要让该用户登录本地主机,必须使用passwd为其设置一个系统密码;若要让该用户可以访问samba服务,必须使用smbpasswd为其设置一个smb访问密码;上述两个密码是独立设置的,当然可以把它们设置成一样的密码。 设置smb访问密码 sudo smbpasswd –a 已有用户名 重启SMB服务器 Sudo service smb restart 二、利用用户名映射,来添加新用户 有时出于出于其它方面的考虑,比如: 1、 为了方便,对于Windows用户来说,习惯于用自己熟悉的用户名,若真的想用自己熟悉的用户名来访问samba服务,就可以使用账号映射,把常用的用户名映射为samba账号。 2、 由于类Unix系统要账号名必须少于8个字符,虽然这个限制在目录的类Unix系统已经得到解决,但是对于samba服务来说,解决这个问题的另一方面,就是启用账号映射,把多于8个字符的用户名映射为类Unix系统的用户名。 为了方便,可以利用用户名映射来添加新用户。 什么是映射 这里的映射类似于数学中映射的概念。在数学中,对于y=f(x),我们说这是x到y的一个映射。按照这个形式,对于式子A = B,我们就可以说“把B映射为A”。 对于samba来说,A才是系统里真正的系统用户,而B只是一个方便记忆的名字,并不存在于系统中。 SMB可以使用用户名列表,具体的吗,不怎么好说清楚,就是说SMB服务器可以设置账号映射,就是说SMB用户可以不是系统用户 启用账号映射 在SMB.conf文件中可以开启用户账号映射,就是启用username map选项,方法: 先打开smb.conf这个文件,找到:username map =/etc/samba/smbusers 这一项,把前面的分号去掉,记住username map= 后面的路径; 如果没有username map这个选项,就在security = user(或share)下添加username map =/etc/samba/smbusers进去则可。 然后手动的编辑/etc/samba/smbusers: 使用命令: vi /etc/samba/smbusers 这个命令是编辑 username map 所指定的那个文件 在这个文件里面添加虚拟用户名 如 root = administrator admin 这里的意思是说 root这个系统用户名有两个虚拟的SMB用户名,一个是administrator,一个是admin;或者说把administrator和admin映射为root. 按这个方法去添加新的用户名,比如你先在系统中添加一个系统用户 命令: sudo useradd username 这个命令是添加一个系统用户账号,账号名是:username , 接着, 在/etc/samba/smbusers这个文件中添加虚拟账号:比如: username = abc aaa aab username是系统账号名 abc,aaa,aab这三个是SMB的虚拟账号,你公司有多少个用户就在这里添加,把他们的用户名都添加到这个文件里面。在设置虚拟帐号时有一个问题要注意,那就是虚拟用户名如果带空格,那么要用双引号把整个用户括起来。 然后在你的smb.conf的文件中建立共享目录,比如 [tmp] path=/tmp public=no valid users=username 保存退出 重启动SMB sudo service smb restart 以下是关于username map的一篇英文资料,有参考意义 Mapping Different Usernames There may be a requirement where the samba username being used to access the server does not match the same UNIX account username, or you would like to force a change between the two different account types. This can easily be done by implementing the "username map" directive into the [global] section of the main configuration file. [bash]# vi /etc/samba/smb.conf [global]    username map = /etc/samba/smbusers The username map feature is fairly simple, the file takes a UNIX account name on the left hand side and Samba account names on the right hand side (separated by "="). The username map allows those NT accounts listed on the RHS to be granted the access rights and file permissions of the UNIX account on the LHS when they connect to a resource. In the following example: · The NT usernames "administrator" and "admin" will be mapped to the UNIX "root" account, · The NT usernames "guest", "pcguest" and "smbguest" will be mapped to the UNIX "nobody" account, · The NT username "alice" will be mapped to the UNIX "alice.jones" account, · All four NT Users (glen, fred, terry and sarah) will be mapped to the single UNIX "readonly" account, and · The NT username "Lachlan Smith" will be mapped to the UNIX "lachlan" account. The last example uses quotes around the NT username because there is a space separating the user's first and last names. Failure to use quotes on an NT username containing a space means that Samba will treat the user's name as two separate UNIX accounts; this will course the connections to fail. [bash]# vi /etc/samba/smbusers # Unix_name = SMB_name1 SMB_name2 ... root = administrator admin nobody = guest pcguest smbguest alice.jones = alice readonly = glen fred terry sarah lachlan = "Lachlan Smith" Further details on mapping usernames can be obtained in the configuration man page, type "man smb.conf".
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传
相似文档                                   自信AI助手自信AI助手

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4009-655-100  投诉/维权电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服