一、说明
ubuntu1604搭建samba服务器
二、环境
ubuntu: 1604版本
三、搭建步骤
1、安装samba工具
sudo apt-get install samba
sudo apt-get install smbclient
2、修改samba配置
修改samba配置,开放对用户名访问samba的权限。
(1)备份配置,防止出错。
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_backup
(2)修改配置,增加用户对samba访问的权限。
vi /etc/samba/smb.conf
找到“Share Definitions”代码段,修改共享规则。
修改为如下
#======================= 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 = 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
# 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
修改完成,保存退出。
3、增加防火墙对samba的支持
对于有些ubuntu,默认是激活状态,不支持samba服务,此时,输入命令增加对samba的支持。
sudo ufw allow Samba
输入完成之后,检查是否增加了对samba的支持。
sudo ufw status
结果显示如下,可以看到samba则说明成功(如果显示 Status: inactive也可以)。
houfei@ubuntu:~$ sudo ufw status
Status: active
To Action From
– —— —-
22 ALLOW Anywhere
Samba ALLOW Anywhere
8090 ALLOW Anywhere
22 (v6) ALLOW Anywhere (v6)
Samba (v6) ALLOW Anywhere (v6)
8090 (v6) ALLOW Anywhere (v6)
4、重启samba服务器
sudo /etc/init.d/samba restart
5、增加samba用户
例如,要增加一个 test用户,首先该用户是ubuntu里面的用户,然后,再将该用户增加至samba服务。
# 增加test用户,用户名为test
sudo adduser test
# 增加test用户至samba服务器
sudo smbpasswd -a test