Project

General

Profile

Adding a Samba server to Nextcloud » History » Version 6

Gareth Eaton, 12/21/2023 02:03 PM

1 1 Gareth Eaton
h1. Adding a Samba server to Nextcloud
2
3
Combining a Samba server with Nextcloud is beneficial because it enables unified file access, scalable file sharing, enhanced security, and seamless collaboration, making it easier for users to manage and share files while providing flexibility for remote and mobile access.
4
5
6
1. **Install Ubuntu and Update**
7
8 2 Gareth Eaton
Install Ubuntu and update your system.
9 1 Gareth Eaton
10
<pre>
11 4 Gareth Eaton
sudo apt install samba
12 1 Gareth Eaton
</pre>
13
14
15 4 Gareth Eaton
Before you can create a Samba user, you need to create a corresponding Linux user account. This account will be used to authenticate with the Samba server.
16
2. **Add User 'nextcloud'**
17
18 1 Gareth Eaton
Add a user named 'nextcloud':
19
20
<pre>
21 4 Gareth Eaton
sudo adduser nextcloud
22 1 Gareth Eaton
</pre>
23
24 4 Gareth Eaton
3. **Create a Group**
25 2 Gareth Eaton
26 1 Gareth Eaton
Create a group named 'nextcloud':
27
28
<pre>
29 4 Gareth Eaton
sudo groupadd nextcloud
30 1 Gareth Eaton
</pre>
31
32 4 Gareth Eaton
4. **Add User 'nextcloud' to Group**
33 1 Gareth Eaton
34
Add the user 'nextcloud' to the 'nextcloud' group:
35
36
<pre>
37 4 Gareth Eaton
sudo usermod -aG nextcloud nextcloud
38 2 Gareth Eaton
</pre>
39 1 Gareth Eaton
40 6 Gareth Eaton
you can check if you add the samba user with - pdbedit -L -v
41
42 4 Gareth Eaton
5. You add the Samba user database using the smbpasswd command:
43
<pre>
44 5 Gareth Eaton
sudo smbpasswd -a nextcloud
45 4 Gareth Eaton
</pre>
46
47 2 Gareth Eaton
6. **Create a Data Directory**
48 1 Gareth Eaton
49
Create a directory for your data:
50
51
<pre>
52 4 Gareth Eaton
mkdir /srv/data
53 1 Gareth Eaton
</pre>
54
55
7. **Set Permissions**
56 2 Gareth Eaton
57 1 Gareth Eaton
Set the ownership and permissions for the data directory:
58
59
<pre>
60 4 Gareth Eaton
sudo chown nextcloud:nextcloud /srv/data
61
sudo chmod 770 /srv/data
62 1 Gareth Eaton
</pre>
63
64
8. **Backup Samba Configuration**
65
66 2 Gareth Eaton
Create a backup of the Samba configuration file:
67 1 Gareth Eaton
68
<pre>
69 4 Gareth Eaton
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.backup
70 1 Gareth Eaton
</pre>
71
72
9. **Edit Samba Configuration**
73
74 2 Gareth Eaton
Edit the Samba configuration file using the Nano text editor:
75 1 Gareth Eaton
76
<pre>
77 4 Gareth Eaton
sudo nano /etc/samba/smb.conf
78 1 Gareth Eaton
</pre>
79
80 2 Gareth Eaton
Add the following configuration to the file:
81 1 Gareth Eaton
82
<pre>
83
   [global]
84
      server min protocol = SMB3
85
      server max protocol = SMB3
86
      ntlm auth = ntlmv2-only
87
      server role = standalone server
88
      obey pam restrictions = yes
89
      unix password sync = yes
90
      passwd program = /usr/bin/passwd %u
91
      passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
92
      pam password change = yes
93
      map to guest = never
94
      encrypt passwords = yes
95
      security = user
96
97
   [Documents]
98
      path = /srv/data
99
      browseable = yes
100
      read only = no
101
      smb encrypt = mandatory
102
      valid users = nextcloud
103
      force group = nextcloud
104
      create mask = 0660
105
      directory mask = 0770
106
</pre>
107
108
10. **Restart Samba**
109
110 2 Gareth Eaton
Restart the Samba service to apply the changes:
111 1 Gareth Eaton
112
<pre>
113 4 Gareth Eaton
sudo systemctl restart smbd
114 1 Gareth Eaton
</pre>
115
116
11. **Review and Make Further Changes**
117
118 2 Gareth Eaton
Review your Samba configuration and make any additional changes as needed.
119 3 Gareth Eaton
120
[[Setting Up and Configuring FileBrowser Service]]