samba配置共享用户home目录

梦想与她 提交于 2020-02-26 13:46:52

1. 先要安装samba

sudo apt-get update
sudo apt-get install samba openssh-server

2. 编辑Samba配置文件

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
sudo vi /etc/samba/smb.conf

找到[homes]项,此项默认是注释掉的,取消其注释,然后修改其具体内容,修改成如下:

#======================= Share Definitions =======================

# Un-comment the following (and tweak the other settings below to suit)
# to enable the default home directory shares. This will share each
# user's home directory as \\server\username
[homes]
   comment = Home Directories
   browseable = no

# By default, the home directories are exported read-only. Change the
# next parameter to 'no' if you want to be able to write to them.
   read only = no

# File creation mask is set to 0700 for security reasons. If you want to
# create files with group=rw permissions, set next parameter to 0775.
   create mask = 0755

# Directory creation mask is set to 0700 for security reasons. If you want to
# create dirs. with group=rw permissions, set next parameter to 0775.
   directory mask = 0755

# By default, \\server\username shares can be connected to by anyone
# with access to the samba server.
# Un-comment the following parameter to make sure that only "username"
# can connect to \\server\username
# This might need tweaking when using external authentication schemes
   valid users = %S

删除多余的信息后,即:

#======================= Share Definitions =======================
[homes]
   comment = Home Directories
   browseable = no
   read only = no
   create mask = 0755
   directory mask = 0755
   valid users = %S

如上修改完成后wq保存退出!

3. 重启samba服务:

sudo service smbd restart && service nmbd restart
# sudo service restart smbd
# sudo service restart nmbd

4. 增加一个现有用户的对应samba帐号:

如我已经有一个用户叫 landaliming,现在给lim开通samba帐号:

sudo smbpasswd -a landaliming

根据提示输入两次密码即可。

5. 现在可以测试了,在Window下输入samba地址尝试登录:

\\10.0.0.2\lim
#注意这里路径,不是 \home\lim

6. 此时windows应该会弹出窗口要求输入用户名和密码了

7. 映射网络驱动

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!