fbpx

Complementing a simple Samba release, this article shows how to create a username and password based Samba share using a Debian 8 based system. Ubuntu 16.04 and Windows 10 are used as client software for testing the connection .

 

Installation and configuration on the Debian server

These following sections show the necessary configuration steps on the Debian server to get the Samba Server up and running. Then the created share can be mounted via a Linux-based or Windows-based client.

Installation of the Samba service

The installation of the Samba service and basic configuration is similar to the article Simple Samba release under Debian .

User-limited configuration

This configuration example now shows how to make an SMB share with authentication . For this, a user smbuser is created on the Debian system and a share entry restricted is added to the configuration file smb.conf .

  1. Creating SMB users, further information can be found in the Wiki article Samba-Server Security in the User Access section .
    $ sudo useradd -s / bin / false smbuser
    
  2. Set password
    $ sudo smbpasswd -a smbuser
    
  3. Entry in the file smb.conf :
[global]
workgroup = smb
security = user
map to guest = never

[Homes]
comment = Home Directories
browsable = no
read only = no
create mode = 0750

[Restricted]
valid users = smbuser
# We restrict access to the user '' smbuser ''
#valid users = @smbusers
#Alternative can also be restricted to a user group
path = / media / storage2 /
public = no
writable = yes
comment = smb restricted share
printable = no
guest ok = no
create mask = 0600
directory mask = 0700

This configuration uses the sample mountpoint / media / storage2 . To restrict access to the share as much as possible, this mountpoint / media / storage2 isassigned to the user smbuser and provided with the directory rights 700 so that only this user (and of course root) receives read and write access.

$ sudo chown -R smbuser: smbuser / media / storage2
$ sudo chmod 700 / media / storage2

Restart of Samba

For the configuration to take effect, you must restart the Samba service. This is done on Debian 8 with systemd .

$ sudo systemctl restart smbd.service

Mount the shares

Now that the Samba server has been completely configured and restarted, the created share can now be used by clients. This is explained using an Ubuntu 16.04 and a Windows 10 client in the following sections.

On a Linux based client

All current Debian-based Linux distributions use the cifs-utils package . Until Ubuntu 12.04 including the old package smbfs could be used.

$ apt-get install cifs-utils

The Samba user smbuser configured on the Debian system is used and the password is queried.

$ sudo mount -t cifs // <IP-of-Samba-Server> / restricted / media / tniedermeier / test -o user = smbuser
Password for smbuser @ // <IP-the-Samba-Server> / restricted: ********

For more information about mounted shares, use the mount terminal call .

On a Windows 10 client

The share can be connected to a Windows 10 client as explained in the following section. There are several ways to connect.

From the command prompt you can connect the network drive with the following command:

C:\Users\tniedermeier>net use <Laufwerksbuchstabe>: \\<IP-des-Samba-Servers>\restricted /user:smbuser <Passwort>

Alternatively, you can connect the network drive through the explorer as explained in the following steps:

If you want to access the share without assigning it a drive letter, you can simply type in the network path directly in Explorer in the entry line:

\\<IP-des-Samba-Servers>\restricted

 

Categories: Tutorials

0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.