Ubuntu 16.04安装配置Samba服务每个用户可以用自己的用户名和密码登录自己的home目录以及共享特定的目录
一、安装Samba命令
sudo apt-get install samba
二、查看samba版本确认是否安装ok
三、配置smb.conf文件 sudo vi /etc/samba/smb.conf,共享home和特定的目录,完整文件可以下载2020-10-20Ubuntu16.04安装配置Samba服务每个用户可以用自己的用户名和密码登录自己的home目录以及共享特定的目录配置smb.conf_ubuntu20添加用户并配置家目录-Linux文档类资源-CSDN下载
找到[homes]项,此项默认是注释掉的,取消其注释,然后修改其具体内容,修改成如下:
[homes]
comment = Home Directories
browseable = yes
# 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 #建议将权限修改成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
# The following parameter makes sure that only "username" can connect
#
# This might need tweaking when using external authentication schemes
valid users = %S #本行需要取消注释
!!!!注意上面的 read only = no,没有这个的话是不能写的!!!!
四、增加samba用户,需要注意的是创建samba用户之前,必须先确保有一个同名的Linux用户(添加新用户useradd username 、passwd password ),否则samba用户会创建失败。
sudo smbpasswd -a smbuser
五、执行下面的命令重新启动samba后才生效。
sudo service smbd restart
或者
sudo /etc/init.d/samba restart
六、查看所有samba用户
sudo pdbedit -L
七、测试ok
八、设置某个共享目录作为公共目录,所有人都可以无密码登陆,但是不可写。添加下面两行。
guest ok =yes
read only = yes