Project

General

Profile

Setting up the smbconf file » History » Version 9

Gareth Eaton, 12/16/2023 04:51 PM

1 1 Gareth Eaton
h1.  Setting up the smbconf file
2
3 6 Gareth Eaton
[[Additional considerations and tips|MORE]]
4 2 Gareth Eaton
5 1 Gareth Eaton
Setting up the smb.conf file for Samba involves configuring the various parameters that define the behavior of your Samba server, including the shared directories, authentication settings, and security options. Here's a basic guide on how to set up the smb.conf file:
6
7
*Backup Your Existing Configuration (Optional):*
8
9
Before making changes, it's a good practice to back up your existing smb.conf file in case something goes wrong. You can do this with the following command:
10
11
<pre>
12
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.backup
13
</pre>
14
15
*Open the smb.conf File for Editing:*
16
17
You can use your preferred text editor to edit the smb.conf file. For example, you can use the nano text editor with the following command:
18
19
<pre>
20
sudo nano /etc/samba/smb.conf
21
</pre>
22
23
*Configure Global Settings:*
24
25
The smb.conf file starts with global settings that apply to the entire Samba server. Some common global settings include:
26
27
<pre>
28
[global]
29
workgroup = WORKGROUP
30
server string = Samba Server
31
security = user
32
encrypt passwords = yes
33
</pre>
34
35
*workgroup:* Set your workgroup or domain name.
36
*server string:* A description of your Samba server.
37
*security:* Set to "user" for user-level security.
38
*encrypt passwords:* Enable password encryption.
39
40 7 Gareth Eaton
*Define Shares:* [[Advanced Configuration Options|More]]
41 1 Gareth Eaton
42
Below the global settings, you can define the shared directories by adding sections like this:
43
44
<pre>
45
[ShareName]
46
path = /path/to/shared/folder
47
valid users = user1, user2
48
read only = no
49
</pre>
50
51 8 Gareth Eaton
You can also use the following
52 1 Gareth Eaton
53 9 Gareth Eaton
*browseable*  = yes: This option controls whether the shared folder is visible and browseable when users access the Samba server from their network neighborhood or file browser. Setting it to "yes" allows users to see the shared folder in the network view.
54 1 Gareth Eaton
55 9 Gareth Eaton
*read only* = no: This option determines whether users have read-only or read-write access to the shared folder. Setting it to "no" means that users can both read and write files in the shared folder, effectively granting them full access.
56
57
*guest ok* = yes: This option allows guest (unauthenticated) access to the shared folder. When set to "yes," users can access the shared folder without providing a username and password. It is useful when you want to create a public or open-access share.
58 8 Gareth Eaton
59
60 1 Gareth Eaton
*ShareName:*  Choose a name for your share.
61
*path:*  Specify the path to the directory you want to share.
62
*valid users:* List the users who are allowed to access this share.
63
*read only:* Set to "yes" for read-only access or "no" for read-write access.
64
65
66
*Configure Share-specific Settings* :
67
68
You can also set specific options for each share. These settings can include access control, guest access, and more.
69
70
*Save and Close the smb.conf File:*
71
72
After making your changes, save the smb.conf file and exit your text editor.
73
74
*Test the Configuration:*
75
76
Before restarting Samba, it's a good idea to test the configuration for syntax errors:
77
78
<pre>
79
testparm
80
</pre>
81
82
*Restart Samba:*
83
84
After verifying the configuration, restart the Samba service for the changes to take effect:
85
86
<pre>
87
sudo systemctl restart smbd
88
</pre>
89
90
*Set Samba Passwords:*
91
92
Ensure that the users you've specified in the valid users parameter have Samba passwords set using the smbpasswd command.
93
94
*Open Firewall Ports (if necessary):*
95
96
If you have a firewall enabled, make sure to allow traffic on the necessary ports (e.g., TCP 139, 445) to allow Samba traffic.
97
98
Test Access:
99
100
Finally, test access to your Samba shares from client machines to make sure everything is working as expected.
101
This is a basic setup of the smb.conf file. Depending on your requirements, you may need to configure additional options such as user-level or share-level security, domain authentication, printer sharing, and more. Be sure to consult the Samba documentation and relevant resources for your specific use case.