Sunday, March 21, 2010

Configuring samba server on Ubuntu (from command line)

This is a basic tutorial which aims to configure samba on an Ubuntu (debian) machine and create a network user for it. Later when I am not as lazy, I will probably elaborate on this, but for the moment this will atleast get you started.


Run the following commands to install and configure samba server. Each command is preceded by the description for it.

Install samba server and dependencies

sudo apt-get install samba

add a default group for accessing samba
sudo groupadd samba-group

create an user for accessing samba and add it to the group created earlier (this will prompt for a password which will be your samba password)
sudo useradd --gid samba-user --shell /bin/false samba-group --home /nonexistent

add the user to the samba password file
sudo smbpasswd -a samba-user

change to your home (cd also works)
cd $HOME

create the share folder
mkdir shared-folder

change the ownership for the share folder and give apt permissions
sudo chown YourUserNameHere:samba-group shared-folder

sudo chmod 775 shared-folder
sudo chmod g+s shared-folder

edit the samba configuration file (i just happen to like vim, but you can use any editor)
sudo vim /etc/samba/smb.conf

in this file

  • Delete the ; in front of security = user, i.e. change to -

security = user,

  • Add the following to the end of the "Share Definitions" section.
    (You will need to change: path = /home/YourUserNameHere/shared-folder).

[sharer]

path = /home/YourUserNameHere/shared-folder

valid users = samba-user

read only = No

create mask = 0777

directory mask = 0777


Now we are done. You should be able to access the samba share from windows system by giving the IP/shared-folder (for e.g. type \\192.168.0.120\shared-folder in start->run). Use the username/password as samba-user/.

No comments:

Post a Comment