Red Hat Samba
id : ofikthrsf0
category : computer
blog : unixlinux
created : 01/05/11 - 11:31:31
Installation
  • First of all install samba :
# yum install samba
# chkconfig smb on

Configuration
  • All configuration files are located in /etc/samba :
    • smbusers : matches between Unix user and Samba users.
    • smbpasswd : Unix user password hashes.
    • smb.conf : samba default configuration file.
smb.conf
  • Global section :
    • netbios name : name by which your Samba server is know.
    • server string : string showed in print manager box.
    • workgroup : this controls what workgroup your server will appear to be in when queried by clients.
    • security : this option affects how clients respond to Samba (share, domain, user, server, ads).
      • user : default security level, use username and password for authentication. (we will use this option).
    • smb passwd file : file used to store password hashes (smbpasswd).
    • username map : file used to store unix/samba matches.
  • Shares section :
    • path : path to share.
    • comment : comment.
    • read only : is this share on read only mode.
    • valid users : who can access this share.
    • create mask : maximum unix right for a file in this share.
    • directory mask : maximum unix right for a directory in this share.
    • force create mode : if a file come from windows windows/unix rights translations will not be applied, force create mode right will be applied.
    • force directory mode: if a directory comme from windows windows/unix rights translations will not be applied, force directory create will be applied.
  • Here is an example :
# vi /etc/smb.conf
[global]
        netbios name    = SAMBA SERVER
        server string   = SAMBA SERVER
        workgroup = SAS
        encrypt passwords = true
        security = user
        smb passwd file = /etc/samba/smbpasswd
        username map= /etc/samba/smbusers
        logs level = 10
        logs file = /var/logs/samba/logs.%m
        max logs size = 50
        name resolve order = host
        lm announce = False
        local master = No
        case sensitive = Auto

[myshare]
        path            = /samba_shares/myshare
        comment         = br share
        read only       = no
        valid users     = myuser
        create mask     = 0750
        directory mask  = 0750
        force create mode = 0750
        force directory mode = 0750

smbpasswd
  • smbpasswd command can be used to populate smbpasswd file, if you want to add a samba user :
# smbpasswd -a myuser

  • to change a samba user password use :
# smbpasswd myuser

  • for example :
# cat /etc/samba/smbpasswd
myuser:41190:DF67CF580CE11EDA24D6C20206F2D80A:6B428BD8CE89541F818114042E2CBF1D:[U          ]:LCT-4CF8D251:
myuser1:41193:4A88969133503D3F063CBF03AAC6ADB8:E08706A165996AB365CA190AD1E1AEDC:[U          ]:LCT-4CF8D1A7:
myuser241196:BAC14D04669EE1D1AAD3B435B51404EE:FBBF55D0EF0E34D39593F55C5F2CA5F2:[U          ]:LCT-4CF8CF94:

smbusers
  • smbuser file is used to match unix names and samba names :
# cat /etc/samba/smbusers
# Unix_name = SMB_name1 SMB_name2 ...
#root = administrator admin
#nobody = guest pcguest smbguest
myuser = SMBUSER
myuser1 = SMBUSER1
myuser2 = SMBUSER2

Links and tricks
  • Matches between windows and unix rights

  • Watch active share on windows :
# net use

  • Delete active share on windows :
# net use <samba_share> /DELETE