What is Samba
- From www.samba.org “Samba is the standard Windows interoperability suite of programs for Linux and Unix.”
- Provides file and print sharing for Windows clients from Linux servers.
- Samba is freely available under the GNU General Public License.
- Install Samba
- Configure Samba
- Add users ( smbpasswd )
- Connect from Windows Client
Installing Samba
- Install from source or ...
- Install from package
- Debian based OS ■ apt-get install samba cifs-utils smbclient
- Fedora based OS ■ yum install samba cifs-utils smbclient
Check for samba processes
After installation samba is generally started automatically
# ps ax | grep mbd
25690 ? Ss 0:16 /usr/sbin/smbd -D
25726 ? S 0:02 /usr/sbin/smbd -D
25742 ? Ss 0:09 /usr/sbin/nmbd -D
Typical samba server processes
Configuring Samba
● smb.conf is the configuration file for samba
● Generally located at /etc/samba/smb.conf
● Detailed and richly commented file with many options explained
Three different smb.conf configs
Today demonstrate three different samba configurations. The first is a very simple two line config to a more complex, but still simple config that includes shared printers and something in between.
smb.conf configuration
● Backup the original
mv smb.conf smb.conf.master
● Create minimal smb.conf using text editor
vim smb.conf
smb.conf file sections
● Enclosed in brackets [ ]
● Each section in the configuration file (except for the [global] section) describes a share
● There are three special sections, [global], [homes] and [printers]
● Any other section describes a shared resource, i.e. [data] or [photos] and how it is shared.
First smb.conf file - two lines!
[homes]
read only = no
● [homes] special section provides access to the users /home/username directory.
● Default of read only=yes so we need to override the default
[homes] special section
A fast and simple way to give a large number of clients access to their home directories with a minimum of fuss.
For example mapping a drive to G: to \\server\homes gives access to files in /home/username on the samba (Linux) server
smbpasswd command
Used to create and manage samba users
smbpasswd -a username
New smb password:
username is the same name as existing linux user name. Password that will be used from Windows client.
smbpasswd username changes a password
Restart samba
- Be sure to restart samba after smb.conf changes.
- Check your changes with testparm.
smbcontrol all reload-config
/etc/init.d/samba restart (Debian)
service smbd restart (Debian)
service smb reload (Fedora)
testing with smbclient
ftp-like client to access SMB/CIFS resources on servers
Test if samba is sharing:
smbclient -N -L localhost
Simiilar to Windows net view command
Connect with smbclient
smbclient -U mmaki //kona/homes
Enter mmaki's password:
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.18] smb: \> smbclient -U mmaki //kona/mmaki Enter mmaki's password: Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.18]
smb: \>
ls ls should give you a file listing
Create a shared share (smb.conf #2)
[share]
comment = Shared Data
path = /home/share
guest ok = Yes
By default shares are read only unless the read only = no option is present. Anyone can access this share but not change or delete anything. Restart samba...
Create the directory on server
# mkdir /home/share
# chown you.you /home/share
From your Linux account you now have complete control of this directory.
No Password Anonymous login
smbclient //localhost/share
A password will be prompted but none need be entered. In fact entering a password will cause it to fail because of the “map guest to” configuration.
Accessing it from Windows
Mapping a drive from Windows such as
\\servername\share connects to /home/share
net use H: \\servername\share gives access to files in /home/share/ on the samba (Linux) server
Current smb.conf
Provides private home directory and a shared directory.
[homes]
read only = no
[share]
comment = Shared Data
path = /home/share
read only = No
guest ok = Yes
Semi-auto smb.conf configuration
● Backup working config
mv smb.conf smb.conf.working
● Create minimal smb.conf using testparm
testparm -s smb.conf.master > smb.conf
testparm generated smb.conf
● Provides private home share.
● Shared printers already established using CUPS (easy printer setup process)
● Other password and miscellaneous configuration settings
● Add other shares if needed (i.e. [shared]) discussed earlier.
testparm command
● Used to check an smb.conf configuration file for internal correctness
● Using it with -s option and directing the output to a file results in a minimal working server with private home directories and existing print shares
● Very convenient starting smb.config
smb.conf #3 private, share, & print
[global]
[printers]
[homes] comment = All printers
guest ok = no path = /var/spool/samba
read only = no create mask = 0700
printable = Yes
[share] print ok = Yes
comment = shared Data browseable = Yes
path = /home/share [print$]
read only = No comment = Printer Driver
guest = Yes path = /var/lib/samba/printers
Connecting to Windows from Linux
smbclient works but very clumsy ftp like client.
mount.cifs <remotetarget> <dir> -o <options>
mount.cifs -o
0 Comments