Simple Samba Configuration

This is an English translation for this article.

With the current Linux distro evolution that making things much simpler to install, installing Samba is easy. Very easy in fact. What you need to do is configuring Samba so, it can fit your requirement.

At my workplace, most people use Windows-based operating system. Most servers also use Windows-based operating system with the exception of DNS, DHCP, and email filtering system. We also have two open source servers that is mainly to host our website.

Because of that, some users need to access the machine using Netbios protocol (although there are much simpler method such as SFTP that is enable by default) to transfer file between their machine and the server.

These are the steps that I used that allow users to access their own home directory in the machine.

1. Edit samba configuration file. The file's name is smb.conf but sometimes it can be named as samba.conf. It is located most probably in /etc/smb.conf or /etc/samba/smb.conf or /etc/sysconfig/smb.conf. If you didn't find the file, use locate or find command.

2. At Global Settings in the configuration file, remove the comment tags for workgroup and hosts allow. Replace the workgroup with your local workgroup name. And limit the computer that can access your samba because with more desktop that can access your server, it will become much more vulnerable towards internal attack (such as worms, viruses, rootkit and other malicious applications).
workgroup = your_local_workgroup
hosts allow = 127. your.local.ip

3. At the Share Definitions, remove comment tags or add [homes] section like this
[homes]
comment = Home Directories
path = /home/%S
browseable = yes
writeable = yes
valid users = %S

4. Save smb.conf and restart Samba daemon
$ /etc/init.d/smb restart

5. Add a new user. The user must exist in your Linux system mean it exist in /etc/passwd. You will be prompted to insert a password. Please don't use the same password as the server login. :)
$ smbpasswd -a new_user
New SMB password:
Retype new SMB password:
Added user new_user.

6. Connect to the server by using a dekstop machine or at the localhost. Its better to use Windows desktop to test the connection. Some machine especially Vista need you to tweak some configuration in the Vista itself before it can connect to the Samba. If you plan to test it just using a commandline (to see it works or not), just run this
$ smbclient -L localhost -Unama_user_baru
passwd : masukkan_passwd_di_sini

7. Samba will display status that notify it works. Most of the time, this configuration will work. Trust me. ^_^

Happy Samba-ing

No comments: