Samba-server basics
A Samba-Server helps with the integration of Windows- and Unix/Linux computers.[1] Files can be, for example, exchanged or printers can be shared. The name Samba comes from the SMB protocol (Server Message Block), which is used for network-based data exchange on Windows. These days, people are increasingly referring to the "Common Internet File System" (CIFS) instead of SMB. CIFS is a further development of SMB and was developed by Microsoft.[2]
A free online book by O'Reilly provides detailed information about Samba/CIFS in German. It is available at Oreilly Samba 2nd edition. Furthermore, the Samba community provides a detailed documentation about Samba: Samba Community. This article presents the basics of working with a Samba server that is set up on Ubuntu 10.04 LTS.
Server
Installation
The Samba package [3] is installed on the server so that a file and print server can be set up.
apt-get install samba
Configuration
The central configuration file is located at
sudo vi /etc/samba/smb.conf
The corresponding man page provides a range of information on how to configure the Samba server using this file:
man smb.conf
The file is divided into several parts. The global section ([global]) includes basic settings that may be followed by other sections on the release of resources.
As the first step in the configuration, comment out the following line in the "Authentication" section:
# "security = user" is always a good idea. This will require a Unix account
# in this server for every user accessing the server. See
# /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/ServerType.html
# in the samba-doc package for details.
security = user
Due to these security measures, an existing user account on the server is required to access the Samba shares.[4]
Network interfaces
If your server possesses multiple network interfaces, it may be that the smb-server is connected to the wrong interface. To do this, the line
interfaces = 192.168.1.1/24
can be added to the "[global]" area of smb.conf. In this example, the SMB server listens on the address range in the 192.168.1.1/24 network.[5]
Add smb password
The following command creates a smb-password for the existing user "smbuser". It is important that this step is performed for an existing user, as every smb-user needs a valid account on the server. The password you set can be used later to access the SMB share:
sudo smbpasswd -a smbuser
As the smb-password does not have to comply with the password of the actual account, it can definitely time-consuming to administrate different passwords. On Ubuntu, the "libpam-smbpass" package exists, which can be used to keep Linux and smb passwords synchronized.
So that the changes are effective, the server must reload the configuration:
sudo service smbd reload
Zuvor können die modifizierten Einstellungen auch auf ihre Korrektheit geprüft werden:
testparm /etc/samba/smb.conf
Add a resource
In the following configuration example, the home directories of the smb-users are released. In the first step, a new resource is added to the "smb.conf" file:
sudo vi /etc/samba/smb.conf
The following paragraph is commented out:
# Un-comment the following (and tweak the other settings below to suit)
# to enable the default home directory shares. This will share each
# user's home directory as \\server\username
[homes]
comment = Home Directories
browseable = yes
Now, the home-directories are available for all users, which means that the users can access each other´s directories (provided, of course, that an SMB password has been set and the user therefore has access to the SMB server). The parameter "browseable" allows Windows users to browse the Samba share using Windows Explorer. To be more restrictive with home directories, the following line can be commented out:
# By default, \\server\username shares can be connected to by anyone
# with access to the samba server. Un-comment the following parameter
# to make sure that only "username" can connect to \\server\username
# This might need tweaking when using external authentication schemes
valid users = %S
Then, for example, the user "tktest" will no longer be able to access the home directory of "smbuser" (from clients perspective):
sudo mount -t smbfs //192.168.56.101/smbuser /media/ -o username=tktest
Password:
mount error(13): Permission denied
Further security measures are presented, for example, on Samba Security (help.ubuntu.com) or Securing samba (samba.org).
Client
Installation
The following package is required for the access on the smb-server on the client:
sudo apt-get install smbfs smbclient
With the smbclient, an initial connection test can be started:
smbclient -U smbuser -L 192.168.56.101
With the mount command, the smb directory can be integrated locally:
sudo mount -t cifs //192.168.56.101/smbuser /media/ -o username=smbuser
After this command, the smb-directory will be accessible at "/media/
References
- ↑ Samba, 2. Auflage www.oreilly.de
- ↑ SMB and CIFS overview (msdn.microsoft.com)
- ↑ Samba Package (packages.ubuntu.com)
- ↑ Samba Security (help.ubuntu.com)
- ↑ http://tldp.org/HOWTO/SMB-HOWTO-6.html
|
Translator: Alina Ranzinger Alina has been working at Thomas-Krenn.AG since 2024. After her training as multilingual business assistant, she got her job as assistant of the Product Management and is responsible for the translation of texts and for the organisation of the department.
|
