Friday, January 15, 2010

Simple Samba/CIFS Configuration

Any time I have to do something with Samba, I run into stupid configuration and permissions issues. I just set up a dead simple Samba config and am documenting it here for next time. Possibly someone else might get some use out of it too.

Some reading I based this on: creating a public share in Samba, and some Samba on Ubuntu docs.

Overview:

  • Ubuntu 9.10 Karmic as the smb server
  • Whatever Samba 3.x it comes with
  • Windows and Linux client machines
  • Anyone on 192.168.1.0/24 has access: not secure, but convenient
  • Machine called myhostname is the file server, at IP 192.168.1.4

Config:

  1. On the file server, myhostname in this example, create a user smbuser to act as the 'guest' in Samba. Client machines that don't authenticate will act as this user:
    sudo adduser smbuser
    Then make sure /etc/passwd and /etc/group have lines something like this:
    # /etc/passwd
    smbuser:x:1001:1001:Samba user,,,:/home/smbuser:/usr/sbin/nologin
    
    # /etc/group
    smbuser:x:1001:
    
  2. Edit /etc/samba/smb.conf:
    [global]
    netbios name = myhostname
    workgroup = WORKGROUP
    server string = File Server
    security = user
    map to guest = bad user
    guest account = smbuser
    create mask = 0644
    directory mask = 0755
    hosts allow = 192.168.1.0/24
    hosts deny = 0.0.0.0/0
    unix extensions = no  # unless you REALLY need them
    
    # Simple share that anyone can read/write to
    [photos]
    path = /data/photos
    browsable = yes
    guest ok = yes
    read only = no
    
  3. Client linux machine's /etc/fstab (Make sure smbfs is installed: sudo apt-get install smbfs):
    //192.168.1.4/data /data cifs username=smbuser,password=,uid=bob,gid=bob 0 0
    
  4. Client Windows machine: just browse to \\192.168.1.4 or \\myhostname

No comments:

Post a Comment