Diese Seite drucken
Freitag, 17 November 2017 19:17

Samba-Server Umbuntu 16.04 (Eng.)

geschrieben von
Artikel bewerten
(0 Stimmen)

{jcomments off}

This guide explains the installation and configuration of a Samba server on Ubuntu 16.04 (Xenial Xerus) with anonymous and secured Samba shares. Samba is an Open Source/Free Software suite that provides seamless file and print services to SMB/CIFS clients. Samba is freely available, unlike other SMB/CIFS implementations, and allows for interoperability between Linux/Unix servers and Windows-based clients.

 

1 Preliminary Note


I have fresh installed Ubuntu 16.04 server, on which I am going to install the samba server. As Samba client system, I will use a Windows Desktop to connect to the samba server and check the setup. The Windows Desktop should be in the same network so that it is able to reach the Ubuntu server. The hostname of my Ubuntu server is server1.example.com and the IP is 192.168.1.100
If you don't have a Ubuntu server already, follow this tutorial to get a minimal server setup as the basis for this tutorial.
Note: The Windows machine must be in the same workgroup. To check the value in the Windows machine run the following command at cmd prompt:

net config workstation

Your Windows machine must be in the same Workstation domain as the Ubuntu server, i.e. WORKGROUP in my case.
To make the windows machine reachable in Windows by its hostname, proceed like this. Open a Windows terminal in administrator mode (you can reach the administrator mode by doing a right-click on the Terminal icon in the program menu) and run the following command to open the Windows hosts file:

notepad C:\\Windows\System32\drivers\etc\hosts

There you add the following red line and save the file:

[...]

192.168.1.100 server1.example.com server1

The following steps have to be run as root user. Run:

sudo -s

on the shell of your Linux server to become the root user.

2 Anonymous Samba sharing


Samba is available in the Ubuntu repositories. The first step is to install the Samba Server and its dependencies with apt.

apt-get install -y samba samba-common python-glade2 system-config-samba

It will install the Samba version 4.3.9-Ubuntu.
To configure samba, edit the file /etc/samba/smb.conf. I will use nano as editor and make a backup of the original file before I start to change it. The backup file is named /etc/samba/smb.conf.bak


cp -pf /etc/samba/smb.conf /etc/samba/smb.conf.bak

cat /dev/null > /etc/samba/smb.conf

Open the Samba configuration file with nano:
nano /etc/samba/smb.conf

And add the following lines.


[global]

workgroup = WORKGROUP
server string = Samba Server %v
netbios name = ubuntu
security = user
map to guest = bad user
dns proxy = no

#============================ Share Definitions ==============================

[Anonymous]
path = /samba/anonymous
browsable =yes
writable = yes
guest ok = yes
read only = no
force user = nobody


Then I'll create a directory for the anonymous share.


mkdir -p /samba/anonymous

Set the correct permissions.

chmod -R 0775 /samba/anonymous

chown -R nobody:nogroup /samba/anonymous

And restart Samba to apply the new configuration.

service smbd restart

Now you can access the Ubuntu sharing in Windows by entering "\\server1" in the windows search field of the menu or use the network browser of the Windows file explorer to connect to the share.

Bild...
Try to upload a file by Drag&Drop to the share to see if it is working correctly.

Bild...

3 Secured Samba server


For the password-protected share, I will create a group smbgrp and user till to access the Samba server. I'll use "howtoforge" as password in this example, please choose a custom and secure password on your server.

addgroup smbgrp

useradd till -G smbgrp  // User "till" zur Gruppe "smbgrp" hinzufügen

smbpasswd -a till

root@server1:~# smbpasswd -a till

New SMB password:<--howtoforge

Retype new SMB password:<--howtoforge


Added user till.


root@server1:~#

Now create the folder with the name "secured" in the /samba folder and give permissions like this

mkdir -p /samba/secured

cd /samba

chmod -R 0770 secured


chown root:smbgrp secured

Edit the Samba configuration file and add the following (red) lines at the end of the file:

nano /etc/samba/smb.conf

[...]
[secured]
path = /samba/secured
valid users = @smbgrp
guest ok = no
writable = yes
browsable = yes

Hier gehts weiter mit der Beschreibung.


Folgende Schritte wurden für die Installation von Samba-Server vorgenommen:

apt-get update

sudo apt-get install samba-common samba

sudo apt-get install samba-doc samba-doc-pdf tdb-tools

apt-get install -y samba samba-common python-glade2 system-config-samba

cp -pf /etc/samba/smb.conf /etc/samba/smb.conf.bak

cat /dev/null > /etc/samba/smb.conf

nano /etc/samba/smb.conf

mkdir -p /samba/anonymous

chmod -R 0775 /samba/anonymous

chown -R nobody:nogroup /samba/anonymous

service smbd restart


Ab hier Konsolen-Text der Installation -------------

root@Linux-Server:~# apt-get update
OK:1 http://archive.ubuntu.com/ubuntu xenial InRelease
Holen:2 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [95.7 kB]
OK:3 http://archive.ubuntu.com/ubuntu xenial-backports InRelease
Holen:4 http://archive.ubuntu.com/ubuntu xenial-security InRelease [94.5 kB]
Ign:5 http://archive.ubuntu.com/ubuntu trusty InRelease
OK:6 http://archive.ubuntu.com/ubuntu trusty Release
OK:7 http://mirrors.cicku.me/mariadb/repo/10.1/ubuntu xenial InRelease
Holen:8 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [408 kB]
Holen:9 http://archive.ubuntu.com/ubuntu xenial-updates/main i386 Packages [403 kB]
Holen:11 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [345 kB]
Holen:12 http://archive.ubuntu.com/ubuntu xenial-updates/universe i386 Packages [341 kB]
OK:13 http://ftp.utexas.edu/mariadb/repo/10.1/ubuntu xenial InRelease
Holen:14 http://archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [123 kB]
Es wurden 1'811 kB in 1 s geholt (1'457 kB/s).
Paketlisten werden gelesen... Fertig

root@Linux-Server:~# sudo apt-get install samba-common samba
Paketlisten werden gelesen... Fertig
Abhängigkeitsbaum wird aufgebaut.
Statusinformationen werden eingelesen.... Fertig
Die folgenden zusätzlichen Pakete werden Installiert
samba-common-bin
Vorgeschlagene Pakete:
bind9 bind9utils ctdb ldb-tools smbldap-tools winbind heimdal-clients
Die folgenden NEUEN Pakete werden installiert:
samba samba-common samba-common-bin
0 aktualisiert, 3 neu installiert, 0 zu entfernen und 15 nicht aktualisiert.
Es müssen noch 0 B von 1'490 kB an Archiven heruntergeladen werden.
Nach dieser Operation werden 13.3 MB Plattenplatz zusätzlich benutzt.

Möchten Sie fortfahren? [J/n] j
Vorkonfiguration der Pakete ...
Vormals nicht ausgewähltes Paket samba-common wird gewählt.
(Lese Datenbank ... 170367 Dateien und Verzeichnisse sind derzeit installiert.)
Vorbereitung zum Entpacken von .../samba-common_2%3a4.3.11+dfsg-0ubuntu0.16.04.1_all.deb ...
Entpacken von samba-common (2:4.3.11+dfsg-0ubuntu0.16.04.1) ...
Vormals nicht ausgewähltes Paket samba-common-bin wird gewählt.
Vorbereitung zum Entpacken von .../samba-common-bin_2%3a4.3.11+dfsg-0ubuntu0.16.04.1_amd64.deb ..
Entpacken von samba-common-bin (2:4.3.11+dfsg-0ubuntu0.16.04.1) ...
Vormals nicht ausgewähltes Paket samba wird gewählt.
Vorbereitung zum Entpacken von .../samba_2%3a4.3.11+dfsg-0ubuntu0.16.04.1_amd64.deb ...
Entpacken von samba (2:4.3.11+dfsg-0ubuntu0.16.04.1) ...
Trigger für man-db (2.7.5-1) werden verarbeitet ...
Trigger für libc-bin (2.23-0ubuntu3) werden verarbeitet ...
Trigger für systemd (229-4ubuntu11) werden verarbeitet ...
Trigger für ureadahead (0.100.0-19) werden verarbeitet ...
ureadahead will be reprofiled on next reboot
Trigger für ufw (0.35-0ubuntu2) werden verarbeitet ...
Regeln für Profil 'Apache Full' aktualisiert
samba-common (2:4.3.11+dfsg-0ubuntu0.16.04.1) wird eingerichtet ...
Creating config file /etc/samba/smb.conf with new version
samba-common-bin (2:4.3.11+dfsg-0ubuntu0.16.04.1) wird eingerichtet ...
samba (2:4.3.11+dfsg-0ubuntu0.16.04.1) wird eingerichtet ...
Trigger für libc-bin (2.23-0ubuntu3) werden verarbeitet ...
Trigger für systemd (229-4ubuntu11) werden verarbeitet ...
Trigger für ureadahead (0.100.0-19) werden verarbeitet ...
Trigger für ufw (0.35-0ubuntu2) werden verarbeitet ...
Regeln für Profil 'Apache Full' aktualisiert

root@Linux-Server:~# sudo apt-get install samba-doc samba-doc-pdf tdb-tools

Paketlisten werden gelesen... Fertig
Abhängigkeitsbaum wird aufgebaut.
Statusinformationen werden eingelesen.... Fertig
Paket samba-doc ist nicht verfügbar, wird aber von einem anderen Paket
referenziert. Das kann heißen, dass das Paket fehlt, dass es abgelöst
wurde oder nur aus einer anderen Quelle verfügbar ist.
Doch die folgenden Pakete ersetzen es:
samba-testsuite:i386 registry-tools:i386 libpam-winbind:i386 samba-testsuite registry-tools lib
samba-common-bin:i386 samba:i386 libsmbclient:i386 winbind smbclient samba-common-bin samba-com

E: Für Paket »samba-doc« existiert kein Installationskandidat.
E: Paket samba-doc-pdf kann nicht gefunden werden.

------------------------------------------------------
root@Linux-Server:~# apt-get install -y samba samba-common python-glade2 system-config-samba
Paketlisten werden gelesen... Fertig
Abhängigkeitsbaum wird aufgebaut.
Statusinformationen werden eingelesen.... Fertig
»samba« ist bereits die neuste Version (2:4.3.11+dfsg-0ubuntu0.16.04.1).
»samba-common« ist bereits die neuste Version (2:4.3.11+dfsg-0ubuntu0.16.04.1).
Die folgenden zusätzlichen Pakete werden Installiert
libglade2-0 libuser1 python-cairo python-gobject-2 python-gtk2 python-libuser
Vorgeschlagene Pakete:
python-gtk2-doc python-gobject-2-dbg
Die folgenden NEUEN Pakete werden installiert:
libglade2-0 libuser1 python-cairo python-glade2 python-gobject-2 python-gtk2 python-libuser sys
0 aktualisiert, 8 neu installiert, 0 zu entfernen und 15 nicht aktualisiert.
Es müssen 1'234 kB an Archiven heruntergeladen werden.
Nach dieser Operation werden 9'895 kB Plattenplatz zusätzlich benutzt.
Holen:1 http://archive.ubuntu.com/ubuntu xenial/main amd64 libglade2-0 amd64 1:2.6.4-2 [44.6 kB]
Holen:2 http://archive.ubuntu.com/ubuntu xenial/universe amd64 libuser1 amd64 1:0.60~dfsg-1.2 [55
Holen:3 http://archive.ubuntu.com/ubuntu xenial/main amd64 python-cairo amd64 1.8.8-2 [41.3 kB]
Holen:4 http://archive.ubuntu.com/ubuntu xenial/main amd64 python-gobject-2 amd64 2.28.6-12ubuntu
Holen:5 http://archive.ubuntu.com/ubuntu xenial/main amd64 python-gtk2 amd64 2.24.0-4ubuntu1 [620
Holen:6 http://archive.ubuntu.com/ubuntu xenial/main amd64 python-glade2 amd64 2.24.0-4ubuntu1 [9
Holen:7 http://archive.ubuntu.com/ubuntu xenial/universe amd64 python-libuser amd64 1:0.60~dfsg-1
Holen:8 http://archive.ubuntu.com/ubuntu xenial/universe amd64 system-config-samba all 1.2.63-0ub
Es wurden 1'234 kB in 0 s geholt (2'153 kB/s).
Vormals nicht ausgewähltes Paket libglade2-0:amd64 wird gewählt.
(Lese Datenbank ... 170618 Dateien und Verzeichnisse sind derzeit installiert.)
Vorbereitung zum Entpacken von .../libglade2-0_1%3a2.6.4-2_amd64.deb ...
Entpacken von libglade2-0:amd64 (1:2.6.4-2) ...
Vormals nicht ausgewähltes Paket libuser1 wird gewählt.
Vorbereitung zum Entpacken von .../libuser1_1%3a0.60~dfsg-1.2_amd64.deb ...
Entpacken von libuser1 (1:0.60~dfsg-1.2) ...
Vormals nicht ausgewähltes Paket python-cairo wird gewählt.
Vorbereitung zum Entpacken von .../python-cairo_1.8.8-2_amd64.deb ...
Entpacken von python-cairo (1.8.8-2) ...
Vormals nicht ausgewähltes Paket python-gobject-2 wird gewählt.
Vorbereitung zum Entpacken von .../python-gobject-2_2.28.6-12ubuntu1_amd64.deb ...
Entpacken von python-gobject-2 (2.28.6-12ubuntu1) ...
Vormals nicht ausgewähltes Paket python-gtk2 wird gewählt.
Vorbereitung zum Entpacken von .../python-gtk2_2.24.0-4ubuntu1_amd64.deb ...
Entpacken von python-gtk2 (2.24.0-4ubuntu1) ...
Vormals nicht ausgewähltes Paket python-glade2 wird gewählt.
Vorbereitung zum Entpacken von .../python-glade2_2.24.0-4ubuntu1_amd64.deb ...
Entpacken von python-glade2 (2.24.0-4ubuntu1) ...
Vormals nicht ausgewähltes Paket python-libuser wird gewählt.
Vorbereitung zum Entpacken von .../python-libuser_1%3a0.60~dfsg-1.2_amd64.deb ...
Entpacken von python-libuser (1:0.60~dfsg-1.2) ...
Vormals nicht ausgewähltes Paket system-config-samba wird gewählt.
Vorbereitung zum Entpacken von .../system-config-samba_1.2.63-0ubuntu6_all.deb ...
Entpacken von system-config-samba (1.2.63-0ubuntu6) ...
Trigger für libc-bin (2.23-0ubuntu3) werden verarbeitet ...
Trigger für man-db (2.7.5-1) werden verarbeitet ...
Trigger für hicolor-icon-theme (0.15-0ubuntu1) werden verarbeitet ...
Trigger für desktop-file-utils (0.22-1ubuntu5) werden verarbeitet ...
Trigger für mime-support (3.59ubuntu1) werden verarbeitet ...
libglade2-0:amd64 (1:2.6.4-2) wird eingerichtet ...
libuser1 (1:0.60~dfsg-1.2) wird eingerichtet ...
python-cairo (1.8.8-2) wird eingerichtet ...
python-gobject-2 (2.28.6-12ubuntu1) wird eingerichtet ...
python-gtk2 (2.24.0-4ubuntu1) wird eingerichtet ...
python-glade2 (2.24.0-4ubuntu1) wird eingerichtet ...
python-libuser (1:0.60~dfsg-1.2) wird eingerichtet ...
system-config-samba (1.2.63-0ubuntu6) wird eingerichtet ...
Trigger für libc-bin (2.23-0ubuntu3) werden verarbeitet ...
root@Linux-Server:~# cp -pf /etc/samba/smb.conf /etc/samba/smb.conf.bak
root@Linux-Server:~# cat /dev/null > /etc/samba/smb.conf
root@Linux-Server:~# nano /etc/samba/smb.conf
root@Linux-Server:~# mkdir -p /samba/anonymous
root@Linux-Server:~# chmod -R 0775 /samba/anonymous
root@Linux-Server:~# chown -R nobody:nogroup /samba/anonymous
root@Linux-Server:~# service smbd restart
root@Linux-Server:~#

---------------------------------------------------------


 

 

Gelesen 1937461 mal Letzte Änderung am Donnerstag, 05 September 2019 08:45
Zenhäusern Jean-Marc

Das Neueste von Zenhäusern Jean-Marc