树莓派安装和配置samba服务器

安装samba服务器

sudo apt-get update
sudo apt-get install samba samba-common-bin

创建共享文件夹,更杠文件夹权限

sudo mkdir /share
sudo chmod -R 777 /share

修改samba配置文件,添加共享文件夹的路径和属性

sudo vim /etc/samba/smb.conf

在文件最后面添加(将后面的注释去掉):

# ======================
[share]           #共享文件的名称, 将在网络上以此名称显示
 comment = Raspberry share folder
path = /share         #共享文件的路径
valid users = pi        #允许访问的用户
browseable = yes        #允许浏览
public = yes        #共享开放
writable = yes        #可写

使用testparm测试配置文件是否正确

testparm

如果执行成功则打印如下内容:

pi@raspberrypi:~ testparm 
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[print]"
Processing section "[share]"
Loaded services file OK.
Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

pi@raspberrypi:~ testparm
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[print]"
Processing section "[share]"
set_variable_helper(true #允许浏览): value is not boolean!
Error loading services.

重启samba服务器

sudo service smbd restart

添加samba用户,这里的用户名要和前面配置文件中设置的用户名一致

sudo smbpasswd -a pi

之后需要输入两次密码,shell打印如下:

New SMB password:
Retype new SMB password:
Added user pi.

使用电脑连接samb服务器,连接前需要保证电脑和树莓派处于同一个局域网下

  • 在windows下使用windows+R组合键,在弹出的输入框中输入树莓派的ip地址
    树莓派安装和配置samba服务器插图
Lyndon
Lyndon

对世界的各种充满着好奇, 探索一切未知.

文章: 37

留下评论

您的邮箱地址不会被公开。 必填项已用 * 标注