Sunday, July 3, 2011

Debian Samba Server

Samba is the protocol by which a lot of PC-related machines share files and printers.
apt-get install samba

Temporary File Space

We will create a simple network share tmp. All users in WORKGROUP will have read-write access. Let create a directory tree (under /srv/smb/) we are going to serve.
mkdir -p /srv/smb/tmp
Place the following in /etc/samba/smb.conf (backup the original file first):
[global]
workgroup = WORKGROUP
server string = Public File Server

# When clients connect to a share level security server, 
# they need not log onto the server with a valid 
# username and password before attempting to connect to
# a shared resource. Instead, the clients send 
# authentication information (passwords) on a per-share
# basis, at the time they attempt to connect to that 
# share.
security = share

# This parameter determines whether or not smbclient(8) 
# and other samba client tools will attempt to 
# authenticate itself to servers using the weaker 
# LANMAN password hash.
client lanman auth = no

# This parameter determines whether or not smbd(8) will 
# attempt to authenticate users or permit password 
# changes using the LANMAN password hash.
lanman auth = no

[tmp]
# If this parameter is yes for a service, then no 
# password is required to connect to the service.
public = yes
comment = Temporary File Space (cleaned up at midnight)
path = /srv/smb/tmp
read only = no
hide files = lost+found
Now from Windows machine you can access this share as \\samba-server-name\tmp. Here is a cron job to make daily clean ups (file /etc/cron.d/clean-samba-tmp):
#
# Regular cron jobs for removing everything 
# in samba tmp share
#
SHELL=/bin/sh

# Run daily at 1:35 AM
# m h dom mon dow user  command
35 1 * * * root /bin/rm -rf /srv/smb/tmp/*
See more configuration options here.

No comments :

Post a Comment