Project

General

Profile

Adding a Samba server to Nextcloud » History » Version 4

Gareth Eaton, 12/21/2023 02:00 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 4 Gareth Eaton
5. You add the Samba user database using the smbpasswd command:
41
<pre>
42
sudo smbpasswd -a sambauser
43
</pre>
44
45 2 Gareth Eaton
6. **Create a Data Directory**
46 1 Gareth Eaton
47
Create a directory for your data:
48
49
<pre>
50 4 Gareth Eaton
mkdir /srv/data
51 1 Gareth Eaton
</pre>
52
53
7. **Set Permissions**
54 2 Gareth Eaton
55 1 Gareth Eaton
Set the ownership and permissions for the data directory:
56
57
<pre>
58 4 Gareth Eaton
sudo chown nextcloud:nextcloud /srv/data
59
sudo chmod 770 /srv/data
60 1 Gareth Eaton
</pre>
61
62
8. **Backup Samba Configuration**
63
64 2 Gareth Eaton
Create a backup of the Samba configuration file:
65 1 Gareth Eaton
66
<pre>
67 4 Gareth Eaton
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.backup
68 1 Gareth Eaton
</pre>
69
70
9. **Edit Samba Configuration**
71
72 2 Gareth Eaton
Edit the Samba configuration file using the Nano text editor:
73 1 Gareth Eaton
74
<pre>
75 4 Gareth Eaton
sudo nano /etc/samba/smb.conf
76 1 Gareth Eaton
</pre>
77
78 2 Gareth Eaton
Add the following configuration to the file:
79 1 Gareth Eaton
80
<pre>
81
   [global]
82
      server min protocol = SMB3
83
      server max protocol = SMB3
84
      ntlm auth = ntlmv2-only
85
      server role = standalone server
86
      obey pam restrictions = yes
87
      unix password sync = yes
88
      passwd program = /usr/bin/passwd %u
89
      passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
90
      pam password change = yes
91
      map to guest = never
92
      encrypt passwords = yes
93
      security = user
94
95
   [Documents]
96
      path = /srv/data
97
      browseable = yes
98
      read only = no
99
      smb encrypt = mandatory
100
      valid users = nextcloud
101
      force group = nextcloud
102
      create mask = 0660
103
      directory mask = 0770
104
</pre>
105
106
10. **Restart Samba**
107
108 2 Gareth Eaton
Restart the Samba service to apply the changes:
109 1 Gareth Eaton
110
<pre>
111 4 Gareth Eaton
sudo systemctl restart smbd
112 1 Gareth Eaton
</pre>
113
114
11. **Review and Make Further Changes**
115
116 2 Gareth Eaton
Review your Samba configuration and make any additional changes as needed.
117 3 Gareth Eaton
118
[[Setting Up and Configuring FileBrowser Service]]