Tuesday, July 12, 2011

Setting up a samba server

Used for sharing files from linux (ubuntu) to windows
1. sudo apt-get install samba

2. sudo gedit /etc/samba/smb.conf
in smb.conf
security = user
usernamemap = /etc/samba/smbusers

3. now it will take the username from the file mentioned
4. first create a password for the username in the file
sudo smbpasswd -a
Now add the username to the file using the commands
sudo gedit /etc/samba/smbusers
  = “

Now we have to create samba shares and give access (i.e) create some directory in the server and give access to the file so that the windows user can read the shared document


 1. open sudo gedit /etc/samba/smb.conf
[global]
 security = share
       client lanman auth = Yes
       lanman auth = Yes

[tmp]
 comment = Temporary file space
 path = /tmp
        read only = n
public = yes
(or)
in the smb.conf (default file)
#======================= 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 = yes
# 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
valid users = %S
# By default, the home directories are exported read-only. Change next
# parameter to ‘yes’ if you want to be able to write to them.
writable = yes
 If you are using the first method then
create a directory named /tmp in ubuntu

Finally
In windows machine
go to run and type
//machinename/hostname
here machine name is the hostname of the ubuntu server

You can find the hostname by typing the command
hostname in terminal.


Once the server and client are setup find out if the directory is shared
1. smbclient -L localhost
 
This will display the name of the folder that is shared
2. How to check whether the folder sharing works properly
mount.cifs //192.168.0.2/tmp /mnt/smb
This command will mount the folder on the location /mnt/smb. If it gets mounted properly then the setup is working properly.

Powered By Blogger