Friday, July 30, 2010

Project - Samba: Configuration

1 Ubuntu part
1.1 Install Samba package
$sudo apt-get install samba

1.2 Configure Samba
Stop Samba
$sudo smbd stop
NOTE: If this does not work, simply replace "smbd" with "/etc/init.d/samba".

Rename and save the deault configuration file.Open an empty file for new configuration.
$sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.template
$sudo touch /etc/samba/smb.conf
$sudo gedit /etc/samba/smb.conf

Edit Samba configuration file smb.conf
[GLOBAL]
[global]
    netbios name = TEST-SAMBA
    server string =
    workgroup = china.messefrankfurt.com
    announce version = 5.0
    socket options = TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192
    interfaces = lo, eth0
    bind interfaces only = true
    passdb backend = tdbsam
    security = user
    null passwords = true
    username map = /etc/samba/smbusers
    name resolve order = hosts wins bcast
    wins support = yes
    printing = CUPS
    printcap name = CUPS
    syslog = 1
    syslog only = yes

1. netbios name : domain name which is the same as configured in Windows.
2. wins support : If your box doesn't have a static ip-address, or you cannot configure your router/server to provide you with a fixed dhcp-lease, change this configuration parameter to "no". In this case you cannot use the benefits of WINS.
3. interfaces : To allow only wired network to have access and that the network card is called eth0.


[HOMES]
NOTE: If you need access to the user home directories, uncomment the lines below and adjust the settings to your hearts content.
;[homes]
    ;valid users = %S
    ;create mode = 0600
    ;directory mode = 0755
    ;browseable = no
    ;read only = no
    ;veto files = /*.{*}/.*/mail/bin/

[NETLOGON]
NOTE: Only needed if you run samba as a primary domain controller.
Not needed as this config doesn't cover that matter.
;[netlogon]
    ;path = /var/lib/samba/netlogon
    ;admin users = Administrator
    ;valid users = %U
    ;read only = no

[PROFILES]
NOTE: only needed if you're running a primary domain controller.
;[Profiles]
    ;path = /var/lib/samba/profiles
    ;valid users = %U
    ;create mode = 0600
    ;directory mode = 0700
    ;writeable = yes
    ;browseable = no

[DVD-ROM Drive]
Uncomment if you need to share your CD-/DVD-ROM Drive.
;[DVD-ROM Drive]
    ;path = /media/cdrom
    ;browseable = yes
    ;read only = yes
    ;guest ok = yes

printers sharing
NOTE: Inside this place you may build a printer driver repository for Windows.
[print$]
    path = /var/lib/samba/printers
    browseable = yes
    guest ok = yes
    read only = yes
    write list = root
    create mask = 0777
    directory mask = 0775
[printers]
    path = /tmp
    printable = yes
    guest ok = yes
    browseable = no

files sharing
This is the name of the share. Leave it as it is or adjust it to whatever you prefer. Don't use more than 31 characters and try to avoid spaces!
[MyFiles]
    path = /home/samba/
    browseable = yes
    read only = no
    guest ok = no
    create mask = 0777
    directory mask = 0755
This suggests that you've mounted an hard drive or partition on /home/samba/ where all the shared files will be stored.
In case you don't have an extra hard drive/partition you may also create folder.


To create the folder.
$sudo mkdir /home/samba
Set permission for the share folder.
$sudo chmod 0777 /home/samba
Start Samba.
$sudo smbd start

Add user and set password.
Enable user account.
NOTE: create Ubuntu account first before using the account as Samba account.
$sudo useradd -s /bin/true riverliu
$sudo smbpasswd -L -a riverliu
$sudo smbpasswd -L -e riverliu

2 Windows part
2.1 Change network settings
- Click "START"
- Click "Control Panel"
- Click "Network Connections"
- Find your "LAN Connection"
- Right-click the icon and select "Properties"
- Select the "TCP/IP" Protocol and click the "Properties" button
- Click "Advanced"
- Select the third Tab entitled "WINS"
- Click "Add"
- Type in the ip-address of your Linux box
- Click "Add"
- Select "Use NetBIOS over TCP/IP"
- Click "OK"
- Click "OK"
- Click "OK"
- Reboot Windows

Upon reboot you may now map the network drive within Windows.
With WINS enabled:
- Click "START"
- Right-click "My Computer"
- Select "Map network drive"
- Choose the drive letter
- Type \\\MyFiles
NOTE: Adjust this to the hostname and sharename you chose above!
- Click "Finish"

With WINS disabled:
- Click "START"
- Right-click "My Computer"
- Select "Map network drive"
- Choose the drive letter
- Type \\\MyFiles
NOTE: To find out the ip-address of your Linux box type "ifconfig" inside a terminal and find the ip for the correct interface (i.e. eth0). Don't forget to adjust the sharename to the name you chose above.
- Click "Finish"

3 Permission
The solution of assign proper permission on specific file/directory is the same as Linux, with the use of command chown, chgrp, chmod.

change files/folders ownership.
$sudo chown -R system_username /directory

change files/folders group ownership.
$sudo chgrp -R system_groupname /directory

change permission.
$sudo chmod -R system_groupname 0700 /directory
The format of permission setting is: dugo = drwxrwxrwx.

NOTE:
1. To use windows authorization, make sue the following setting are confirmed for the specific Samba user:
    - set the Samba-username as Windows-username
    - set the Samba-password as Windows-password

2. Remember to restart Samba after modification of smb.conf

0 comments:

Post a Comment