Tuesday, April 28, 2009

Setup Samba on Ubuntu

Here is a quick guide to setting up a Samba share on Ubuntu Linux.

Install the package

sudo apt-get install samba smbfs
Edit smb.conf
Open the samba configuration file in your favourite editor, change security to user and add a username map.
sudo vi /etc/samba/smb.conf
# "security = user" is always a good idea. This will require a Unix account # in this server for every user accessing the server. See # /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/ServerType.html # in the samba-doc package for details. security = user username map = /etc/samba/smbusers
Create a samba user
sudo smbpasswd -a fahd
Add the new user to the smbusers file
The format is "unix username" = "samba username".
sudo vi /etc/samba/smbusers
fahd = fahd
Share home directory
Make the following changes to smb.conf in order to share your home directory over samba and make it writable.
sudo vi /etc/samba/smb.conf
#======================= Share Definitions ======================= # Un-comment the following (and tweak the other settings below to suit) # to enable the default home directory shares. This will share each # user's home directory as \\server\username [homes] comment = Home Directories browseable = no # By default, the home directories are exported read-only. Change the # next parameter to 'no' if you want to be able to write to them. read only = no # By default, \\server\username shares can be connected to by anyone # with access to the samba server. Un-comment the following parameter # to make sure that only "username" can connect to \\server\username # This might need tweaking when using external authentication schemes valid users = %S
Connecting to the samba
Now you should be able to map a drive on windows using the following share format: \\ubuntumachine\username. The first time you will be prompted for a username and password.

Restarting samba

sudo /etc/init.d/samba restart