How to get a basic Samba setup up and running.
Tested on FreeBSD 6
Samba is a powerful application capable of performing many functions.
In this howto I will explain howto to get basic file sharing working with your Microsoft machines.
First you need to install Samba so,
# cd /usr/ports/net/samba3
# make install clean
This should place a startup script in /usr/local/etc/rc.d called samba.sh
# chmod 700 /usr/local/etc/rc.d/samba.sh
Now edit you rc.conf to start samba on boot.
# vi /etc/rc.conf
Add
samba_enable=”YES”
Now create a configuration file for samba to use.
# vi /usr/local/etc/smb.conf
Add
[global]
netbios name = COMPUTERNAME
workgroup = WORKGROUP
security = user
log file = /var/log/samba.log
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=8192 SO_SNDBUF=8192
os level = 99
[homes]
read only = no
guest ok = no
browseable = no
Change COMPUTERNAME and WORKGROUP to your liking.
The homes section will setup a share for each users home directory.
Windows users will only see the directory for the user that they are logged into.
If you want to setup a normal share that everyone who is authenticated can see, add this to smb.conf
[sharename]
path = /path/to/shared/directory
read only = no
guest ok = no
The port sets up a directory called /var/log/samba which I delete, but that is up to you.
# cd /var/log
# rm -rf samba
# touch samba.log
# chmod 600 samba.log
Now set your newsyslog.conf to rotate the files, add this to /etc/newsyslog.conf
/var/log/samba.log 600 3 300 * Z
If you don’t understand this man newsyslog
With this configuration you must have a real unix user account for each samba account.
These should match the username on the Microsoft machine you will be connecting with.
example from 5.3
home# adduser
Username: testuser
Full name:
Uid (Leave empty for default):
Login group [testuser]:
Login group is testuser. Invite testuser into other groups? []:
Login class [default]:
Shell (sh csh tcsh bash nologin) [sh]: bash
Home directory [/home/testuser]:
Use password-based authentication? [yes]:
Use an empty password? (yes/no) [no]:
Use a random password? (yes/no) [no]:
Enter password:
Enter password again:
Lock out the account after creation? [no]:
Username : testuser
Password : *****
Full Name :
Uid : 1004
Class :
Groups : testuser
Home : /home/testuser
Shell : /usr/local/bin/bash
Locked : no
OK? (yes/no): y
adduser: INFO: Successfully added (testuser) to the user database.
Add another user? (yes/no): n
You may wish to change the default shell to /sbin/false or something similar so that this username cannot login through ssh, etc…
After you have setup the the unix user, you must setup the samba username.
Use the same password that you use on your Microsoft machines so you will not have to login to access your shares.
It is not recommended, but smbpasswd will take a blank password in case you don’t use one on your Microsoft machine.
# smbpasswd -a testuser
New SMB password:
Retype new SMB password:
Added user testuser.
You should now be ready to start the samba daemons.
# /usr/local/etc/rc.d/samba.sh start
# ps -waux | grep mbd
root 16158 0.0 0.6 5360 3096 ?? Ss 8:20PM 0:00.09 /usr/local/sbin/nmbd -D -s /usr/local/etc/smb.conf
root 16164 0.0 0.9 7120 4600 ?? Is 8:20PM 0:00.01 /usr/local/sbin/smbd -D -s /usr/local/etc/smb.conf
root 16166 0.0 0.9 7120 4624 ?? I 8:20PM 0:00.00 /usr/local/sbin/smbd -D -s /usr/local/etc/smb.conf
root 16168 0.0 1.0 7488 4984 ?? S 8:21PM 0:00.05 /usr/local/sbin/smbd -D -s /usr/local/etc/smb.conf
Provided you don’t have the MS stuff blocked in your firewall, you should be able to test your setup now.
Now try to connect from your Microsoft machine
C:> net view \\COMPUTERNAME
Shared resources at COMPUTERNAME
Samba 3.0.9
Share name Type Used as Comment
——————————————————————————-
testuser Disk Home directory of testuser
The command completed successfully.
C:>net use z: \\COMPUTERNAME\testuser
The command completed successfully.
You should now have a mapped drive to your BSD Machine.
|
March 1st, 2006 at 7:48 am
Nice, clean and concise. This article succeeded where others failed. It worked well on FreeBSD6.
Thanks.
March 9th, 2006 at 6:01 pm
I agree. This is by far the most simple and effective tutorial on samba 3 I have come across. Got it up and running in less than 10 mins. I too am on FreeBSD6.
March 22nd, 2006 at 4:20 am
I’m too on FreeBSD6 and have searched around many times about samba tutorials.
This one is the most concise and simple I ‘ve ever found.
Thanks
May 29th, 2006 at 12:54 am
Thanks very much! A year and a half after you wrote this piece, it indeed remains quite applicable; worked wonderfully in freebsd6. All other references I’ve perused prior to this point were outdated and rambling. Many, many thanks for providing precisely what I needed to know.
October 19th, 2006 at 6:15 am
Thanks alot….make my life easier….
November 28th, 2006 at 6:16 pm
Worked first time! Was suprised to see it working first time! One for the server reference folder! Many thanks!
January 25th, 2007 at 3:32 pm
Thank you for an excellent article! My experience with samba is all Linux-based…so the transition was painful until I read your article! Bravo!
March 15th, 2007 at 12:55 pm
Chucks… I’ve upgraded my box to 6.2 and after I re-applied the above guide, plus my old smb.conf, I can see all the shares but I cannot access any of them. I’ve also tried to remove all the shares & users and start from scratch but still the same problem occurs.
Also, the samba.sh does not exists anymore in 6.2 (samba-3.0.23c)
Help!! :((((
March 16th, 2007 at 7:34 am
Woohoo! Got it re-installed one more time and it magically worked again.
April 6th, 2007 at 5:30 am
The latest port version 3.0.24 creates a file /usr/local/etc/rc.d/samba rather than /usr/local/etc/rc.d/samba.sh and it takes ages to start up? Any ideas?
FreeBSD 6.2 with Samba 3.0.24 running inside a jail bound to one ip
April 10th, 2007 at 11:21 am
Thanks for concise instructions. Installed on 6.2, seemed to require hosts/hosts.allow entries for local 192.168. network in order to authenticate XP user. Had no problem with rc.d/samba vs. samba.sh, and no noticeable delay on startup.
May 30th, 2007 at 4:13 pm
Thanks great tutorial.. and works fine. I use FreeBSD 6.2
October 14th, 2007 at 9:11 am
Worked like a charm on 6.2, thanks.
October 28th, 2007 at 2:56 pm
Great Tut. Worked Like a Charm!
Thanks from Jason over at BodyLanguageForBusiness.Com
February 22nd, 2008 at 1:13 pm
ei! thanks for this easy and very clear instructions….
but i have a problem though. I want to configure a server that would let me set up my samba shares with my other unix/freebsd terminals. is it possible?
help please….