***Setting up Samba on Linux***
Samba is a Unix/Linux application that adds SMB (Server Message Block) protocol abilities. This protocol is used by many operating systems, including Windows and OS/2. This guide will show how to set up Samba to allow a Unix/Linux machine to share files.
As an example... I set up Samba on a Bonzai Linux machine for use as a network file server for my home network.
For this guide, I am assuming:
- You have Debian Linux or a Debian-based Linux Distribution installed (ex. Bonzai)
Note: this guide can be applied to other distributions, but file locations and commands may be different. - Your distribution sources list is set up properly
- You know the basics of networking and sharing files
- You are logged in as root
- If you do not have the apt-get command, you know how to compile and make packages (links for Samba and SWAT downloads at the bottom)
# denotes commands typed in the shellSeveral Samba related tools are available, for this guide I will only be installing SWAT (Samba Web Administration Tool), a web interface for configuring Samba.
Installing SambaSamba only:#apt-get install samba
Samba and SWAT:#apt-get install samba swat
It will ask you a few basic questions about the Samba configuration, enter the correct information for your needs.
Create a directory to shareThe following commands are only examples#cd /home/user
#mkdir shared
Set up the password file#cd /etc
#vim smbpasswd
Type :wq and press enter to save and quitConfigure Samba configuration file(If you have KDE or Gnome installed, it may be easier to edit the config files from there unless you know how to use vi or vim)The configuration file is typically located at /etc/samba/smb.confSample configuration file:
[global]
netbios name = fileserver
server string = %h server (Samba %v)
smb passwd file = /etc/smbpasswd [i]<-- edit this line[/i]
passdb backend = tdbsam, guest
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\sUNIX\spassword:* %n\n *Retype\snew\sUNIX\spassword:* %n\n .
syslog = 0
log file = /var/log/samba/log.%m
max log size = 1000
load printers = no
ldap ssl = no
invalid users = root [i]<-- recommended[/i]
valid users = user
admin users = user
write list = user
hosts allow = 192.168.0., 127.0.0.1
hosts deny 0.0.0.0/0
map hidden = Yes
[shared]
comment = Shared Files
path = /home/user/shared
read only = no
create mask = 0755
delete readonly = Yes
guest ok = no
case sensitive = no
The above sample file allows connections only from 192.168.0.* and sets up a shared folder at /home/user/shared with read/write permissions, accessible only by user. It disallows root from accessing shared folders (recommended for security purposes)
Check the config file:#testparm
Restart the server for changes to take effect:#/etc/init.d/samba restart
Now that the configuration file is set up, add users.#adduser user
(If the user doesn't exist already)Enter the requested information.
#smbpasswd -a user
(Note: user must be an existing user on the system)Enter the password at the prompt and press enter.
To map a drive from Windows:Right-click on My Computer -> Map Network Drive... -> Pick a drive letter, type \\fileserver\shared -> Check Reconnect at logon if desired -> Click Finish -> enter username and password when requested.
Complete!
Use SWAT to change settings and manage Samba at
http://fileserver:901Log in with username and password you set up, or root for full configuration access.
Links:
http://www.samba.orgDownload SambaSamba DocumentationSWAT should be installed with Samba if you compiled Samba yourself.
To set up SWAT, edit /etc/inetd.conf or /etc/xinetd.conf and add:
# Swat Samba Web Admin Tool
service swat
{
port = 901
socket_type = stream
wait = no
only_from = 127.0.0.1
user = root
server = /usr/local/samba/sbin/swat
log_on_failure += USERID
disable = no
}
(Code from
http://www.geekspeek.org)
Guide written by php