How to install and configure Samba on Ubuntu 14.10

ubuntu samba

Samba is an implementation of services and protocols compatible with SMB (now called CIFS) with which Windows computers communicate with each other: It was developed by Andrew Tridgell through reverse engineering, using Wireshark-style traffic grabbers (formerly known as Ethereal) to offer compatibility in * nix environments, something that was needed to avoid being isolated in corporate and educational environments in which several platforms usually coexist (Windows, Linux, Mac OS X).

Let's see then how to install and configure Samba on Ubuntu 14.10 Utopic Unicorn, ready for offer anonymous shares and also more secure ones in which it is necessary to authenticate to access, in order to offer files to all types of users. And we are going from the base that we have installed Ubuntu 14.10 server, the version of the Canonical distro dedicated to these matters, with a fixed IP address of 192.168.1.100; In addition to this, of course we will need some other equipment in the same local network, and within the same workgroup, to test how everything has been configured.

Install Samba

To begin, we are going to install the Samba packages, something very simple since they are part of the official repositories:

# apt-get install samba samba-common python-glade2 system-config-samba

Configure Samba

configure samba

Now what we will have to do is edit the /etc/samba/smb.conf file, which is the one that carries all the configuration of our Samba server. Prior to this we make a backup of the current file:

# cp /etc/samba.conf /etc/samba/smb.conf.back

Now if we edit the main file:

# nano /etc/samba/smb.conf

We edit the [global] section, which is where we specify the name of the workgroup, the string with which it is identified in the local network, the netbios name, security type and others. We leave it as follows (we can change the first three parameters if we wish):

[global]
workgroup = WORKGROUP
server string = Samba server% v
netbios name = free
security = user
map to guest = bad user
dns-proxy=no

Next we go well down in the file, to the section that says 'Share Definitions' and that starts with [Anonymous]. There we add (of course, we can change the path to the folder that we are going to share):

[Anonymous]
path = / samba / anonymous
browsable = yes
writable = yes
guest ok = yes
read only = no

Now we restart the samba server:

# service smbd restart

A couple of aspects to consider are the fact that the folder that we are going to offer for anonymous access must exist in our file system and must also be accessible to all users, that is, when listing it with:

Ls -l

It should show us read and execute permissions for everyone, that is drwxr-xr-x, or 755 in numerical jargon. If this is not the case we must make it so (we change 'folder to share' by the name and path that we want):

# chmod -R 0755 / sharefolder

Once we have configured the anonymous access let's do the same with him password restricted access, and this is something that takes a little more work, so let's get started. First of all, since in the general configuration we established that security is through user, this means that to access the protected folders we will have to do it using the username and password that exists on the server Ubuntu 14.10 Utopic Unicorn, and therefore we will have to create that account (we can use the name we want, instead of usersamba as we have done):

# useradd usersamba -G sambashare

We enter the user's password when prompted, and then add the samba password:

# smbpasswd -a usersamba

We will also be asked to enter the password twice, after which the user we have created will already have their Samba password. Now we must add the configuration options to share a password protected folder, so we reopen the Samba configuration file for editing.

# nano /etc/samba/smb.conf

We add:

[safe access]
path = / home / samba / shared
valid users = @sambashare
guest ok = no
writable = yes
browseable = yes

The folder / home / samba / shared must have read, write and execute access for the entire sambashare group, so for this we are going to execute:

# chmod -R 0770 / home / samba / shared

#chown -R root: sambashare / home / samba / shared

That's it, we've already been able configure Samband with this we can access this folder from any computer on the local network that is part of the workgroup WORKGROUP, and by doing so we can even save the password for future faster access from Windows, Mac OS X or from other Linux computers.

Video edition
Related article:
Best Free Video Editors for Ubuntu