Thursday, March 19, 2009

How to setup a Linux Debian Etch/Lenny Samba Server

Today, I would like to share my experience on how to setup a Linux Debian Etch Samba Server. I believe it works for Debian Lenny as well because I have upgraded my Linux Debian Etch Samba Server to Lenny successfully without any issues.

Here are the steps.

1. Setup a normal Debian Etch or Lenny server.

2. Install basic packages by using apt-get install such as ssh, sudo, apache2, php5, phpsysinfo and etc

3. Install Samba packages - samba, samba-common, samba-doc, smbfs, smbclient and swat

4. After install the packages, it's time to configure Samba for your clients.

First, add your clients by using adduser command.

# adduser john

Then disable remote login such as ssh, by editing file /etc/passwd

# vi /etc/passwd

Change /bin/sh to /bin/false for user john

# john:x:1002:1002:,,,:/home/john:/bin/false

Save the file.

Secondly, add related group to enable users in the group to share files.

Add group command

# addgroup itgroup

Add related users into the group

# vi /etc/group

# itgroup:x:1003:john (user john is added into itgroup to share files)

Save the file.

Now it's the time to configure Samba. Remember that we have installed swat during the step 3 above. It is Samba Web administration tool. To access this web page, go to http://ipaddress:901

It will prompt out username and password to login. To login, please use root and root password. You can configure anything inside the web.

Here's my working Samba configuration in /etc/samba/smb.conf

# Samba config file created using SWAT
# from 192.168.xxx.xx (192.168.xxx.xx)
# Date: 2008/12/17 12:35:30

[global]
  workgroup = IT
  netbios name = SAMBA
  server string = %h server
  encrypt passwords = false
  passwd program = /usr/bin/passwd %u
  passwd chat = *Enter\snew\sUNIX\spassword:* %n\n *Retype\snew\sUNIX\spassword:* %n\n *password\supdated\ssuccessfully* .
  syslog = 0
  log file = /var/log/samba/log.%m
  max log size = 1000
  os level = 64
  local master = No
  domain master = No
  dns proxy = No
  wins support = Yes
  panic action = /usr/share/samba/panic-action %d
  invalid users = root
  read list = john
  write list = jay (edit write list follow your own needs, write list users are users that own the folders)

hosts allow = 192.168.1.0/24, 192.168.2.0/24

[homes]
  comment = Home Directories
  valid users = %S
  create mask = 0700
  directory mask = 0700
  browseable = No

[printers]
  comment = All Printers
  path = /var/spool/samba
  create mask = 0700
  printable = Yes
  browseable = No

[print$]
  comment = Printer Drivers
  path = /var/lib/samba/printers
  read only = No
  browseable = No

[winreg]
  comment = registry for windows
  path = /usr/share/doc/samba-doc/registry
  guest ok = Yes

[data]
  comment = Data Directories
  path = /data
  admin users = jay
  force user = jay 
  force group =  itgroup
  read only = No
  create mask = 0640
  directory mask = 0740 (only folder owners can edit the file)
  inherit permissions = Yes (This setting will preserve the  group permissions and ownership although the file owners have edited the files) 
  inherit acls = Yes

You can manually edit the samba configuration or edit the file by using swat. Both is the same. Remember to restart samba service whenever you change any settings in the samba configuration file.

Restart samba command -> # /etc/init.d/samba restart

After that, set samba password for your user login by using smbpasswd command.

# smbpasswd -c /etc/samba/smbpasswd (create a file to store samba password)

# smbpasswd -a john (add user john into the samba password file) 

# smbpasswd -x john (delete user john from the samba password file)

After you have added related users, it is time for your clients to connect the samba server. Before that, your Windows client need to install the windows registry file in the samba server to enable blank username and password for Windows access. It has been configured in my configuration file above. The windows registry path is located at /usr/share/doc/samba-doc/registry

To access your samba server from Windows PC, type IP address and then access the folders. It will prompt out login name and password. If you are able to login with the correct password that created earlier, then your linux Samba server is ready for implementation. It's that simple. 

More tips and tutorials coming soon. Enjoy!!!

No comments:

Post a Comment