• Joel

Setting up an SMB share for your Nextcloud server

Updated: Apr 19


Prerequisites

You need to have completed these two previous guides in this series, before completing this guide:

  1. How to install Nextcloud on a Raspberry Pi

  2. Setting up iNotifyScan for your Nextcloud server

Introduction

In this tutorial, we'll show you how to create an SMB share of your Nextcloud files. This means you'll be able to quickly add, edit, remove content from your Nextcloud, using your PC/Laptop; without the need of having to use the web interface.


Let's get started...

Installing Samba

Connect to your Pi using SSH. Download and install Samba, by running the following:

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

During the installion, you'll be prompted to allow information to be read from a dhcp file for the purpose of WINS. Select 'No' for this.

Setting up SMB shares

Now that Samba's installed, run the following command to edit the Samba configuration file; this is where we'll create the shares for the Nextcloud users:

$ sudo nano /etc/samba/samba.conf

This is a large configuration file, with many options for you to choose from. However, we're here just to add SMB shares. In the example below, we're adding two SMB shares; Admin and Bob. These are two Nextcloud users; as you can see below, the path's to the shares are directed to the mounted HDD, where the Nextcloud user data is stored. In the Admin share, we've added a 'valid users' option, which only grants access to the Admin share, to the users listed within that option. In this example, we've only listed the pi user. Remember, these users are the Raspberry Pi users, not the Nextcloud users. Save the file by pressing <Ctrl> + x followed by y and then press <Enter>:

[Admin-Share]
path = /media/data/Admin/files
valid users = pi
comment = No comment
writeable=Yes
create mask=0777
directory mask=0777
public=no

[Bob]
path = /etc/data/Bob/files
comment = No comment
writeable=Yes
create mask=0777
directory mask=0777
public=no user

At the moment, we only have the user pi setup for the Raspberry Pi. We now need to add pi as a Samba user. Enter the following command and create a password, we recommend that you use the same password as you pi user:

$ sudo smbpasswd -a pi

*Note, you can create other users in your Raspberry Pi and then create the same Samba users


Now you'll just need to restart to the Samba service:

$ sudo service smbd restart

That's it for the PI side of things. You'll now need to map this share on your computer. In this example, we're using Windows, although the same can be done in Linux and MacOS.

First of all, access 'This PC' from the Start Menu, then choose Map Network Drive:

Then, enter the IP address of your Raspberry Pi in the format shown below, then the name of the share that you created in the Samba.conf file:


You'll then be asked for your credentials. These will be the credentials you setup for the Samba user.


*Note: In our example, we added pi to the 'valid users' option in the Samba config file for the 'Admin-Share' SMB share. This means no other user would be able to access it. However, in the 'Bob' SMB share, we didn't specify the 'valid users' option, which means any user could map to the 'Bob' share.


If you haven't already, you MUST now complete the 'Setting up iNotifyScan for your Nextcloud server'. If you don't do this, any changes you make in the SMB shares that you've mapped will not be recorded in the Nextcloud database, and therefore will not show in the Nextcloud app, or web interface. This includes adding/deleting/editing files, so the next guide is absolutely essential.

47 views
  • Facebook
  • Instagram

©2020 by BitProof Web design