Sie sind auf Seite 1von 12

Samba Server Installation on Debian 8 (Jessie)

https://www.howtoforge.com/tutorial/debian-samba-server/

English |

Deutsch

Log in or Sign up

 Tutorial search

Tutorials

Samba Server Installation on Debian 8 (Jessie)

Samba Server Installation on Debian 8 (Jessie)


This tutorial explains the
installation of a Samba fileserver
on Debian 8 (Jessie) and how to
configure it to share files over
the SMB protocol as well as how
to add users. Samba is
configured as a standalone
server, not as a domain
controller. In the resulting setup,
every user has his own home
directory accessible via the SMB
protocol and all users have a
shared directory with read-/write
access.

1 de 12

This tutorial exists for these OS versions


Debian
Debian
Debian
Debian

7 (Wheezy)
6 (Squeeze)
5 (Lenny)
4

Author:
Published:
Tags:

Till Brehm
Aug 05, 2015
debian, samba, storage

On this page
1 Preliminary Note
2 Installing Samba
3 Adding Samba Shares
3.1 Group share
3.2 Home directories

16/11/2015 23:26

Samba Server Installation on Debian 8 (Jessie)

https://www.howtoforge.com/tutorial/debian-samba-server/

Samba Server on Debian 8


(Jessie) as virtual
machine image download
in ovf format, compatible
with VMWare and
Virtualbox.
Download:
Guide:

Debian_8_Samba_Server.ova
VMWare Image Import Guide.

Other Downloads:

Tweet

List of all VMWare Images

67

Recommend

65

13

2 de 12

16/11/2015 23:26

Samba Server Installation on Debian 8 (Jessie)

https://www.howtoforge.com/tutorial/debian-samba-server/

3.3 Anonymous share


4 Adding and Managing Users

3 de 12

16/11/2015 23:26

Samba Server Installation on Debian 8 (Jessie)

1 Preliminary Note

https://www.howtoforge.com/tutorial/debian-samba-server/

5 Accessing Samba from Windows


6 Links

I'm using a Debian 8 system here with the hostname debian.example.com and the IP address
192.168.1.100.
I will use the nano editor in this tutorial to edit
config files on the shell. Nano can be installed
with the command:

apt-get install nano

If you have a different favorite shell editor like


joe or vi, then use that instead.
To make the Linux server accessible by name
from my Windows workstation, I will add a line
to the hosts file on Windows. Run this command
as Administrator user on Windows:

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

and add a line like this:


192.168.1.100

debian.example.com

debian

at the end of the file. Replace the IP address with the server IP and the hostname with the hostname
that you have chosen for your server.

4 de 12

16/11/2015 23:26

Samba Server Installation on Debian 8 (Jessie)

https://www.howtoforge.com/tutorial/debian-samba-server/

2 Installing Samba
Connect to your server on the shell as root user and install the Samba packages:

apt-get install libcups2 samba samba-common cups

Move the current smb.conf file to smb.conf.bak:

mv /etc/samba/smb.conf /etc/samba/smb.conf.bak

And then create a new file smb.conf file:

nano /etc/samba/smb.conf

With the following content:


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

Replace WORKGROUP with the workgroup name that is used on your Windows clients. If you don't
know the name of the workgroup, run this command on the Windows client to get the workgroup
name:

5 de 12

16/11/2015 23:26

Samba Server Installation on Debian 8 (Jessie)

https://www.howtoforge.com/tutorial/debian-samba-server/

net config workstation

Then close the Samba configuration file on the server and restart Samba:

systemctl restart smbd.service

3 Adding Samba Shares


Now I will add a share that is accessible by all users.
Create the directory for sharing the files and change the group to the users group:

mkdir -p /home/shares/allusers
chown -R root:users /home/shares/allusers/
chmod -R ug+rwx,o+rx-w /home/shares/allusers/

mkdir -p /home/shares/anonymous
chown -R root:users /home/shares/anonymous/
chmod -R ug+rwx,o+rx-w /home/shares/anonymous/

At the end of the file /etc/samba/smb.conf add the following lines:

nano /etc/samba/smb.conf

3.1 Group share

6 de 12

16/11/2015 23:26

Samba Server Installation on Debian 8 (Jessie)

https://www.howtoforge.com/tutorial/debian-samba-server/

This is a share that is accessible and writable for all members of our "users" group. Add the following
config at the end of the smb.conf file.
[allusers]
comment = All Users
path = /home/shares/allusers
valid users = @users
force group = users
create mask = 0660
directory mask = 0771
writable = yes

3.2 Home directories


If you want all users to be able to read and write to their home directories via Samba, add the
following lines to /etc/samba/smb.conf (make sure you comment out or remove the existing
[homes] section):
[homes]
comment = Home Directories
browseable = no
valid users = %S
writable = yes
create mask = 0700
directory mask = 0700

3.3 Anonymous share


You like to have a share were all users in your network can write to? Be careful, this share is open to
anyone in the network, so use this only in local networks. Add an anonymous share like this:
[anonymous]

7 de 12

16/11/2015 23:26

Samba Server Installation on Debian 8 (Jessie)

https://www.howtoforge.com/tutorial/debian-samba-server/

path = /home/shares/anonymous
force group = users
create mask = 0660
directory mask = 0771
browsable =yes
writable = yes
guest ok = yes

Now we restart Samba:

systemctl restart smbd.service

4 Adding and Managing Users


In this example, I will add a user named tom.
You can add as many users as you need, in the
same way, just replace the username tom with
the desired username in the commands.

useradd tom -m -G users

Set a password for tom in the Linux system user database. If the user tom should not be able to log
into the Linux system, skip this step.

passwd tom

8 de 12

16/11/2015 23:26

Samba Server Installation on Debian 8 (Jessie)

https://www.howtoforge.com/tutorial/debian-samba-server/

-> Enter the password for the new user.


Now add the user to the Samba user database:

smbpasswd -a tom

-> Enter the password for the new user.


Now you should be able to log in from your Windows workstation with the file explorer (address is
\\192.168.1.100 or \\192.168.1.100\tom for tom's home directory) using the username tom
and the chosen password and store files on the Linux server either in tom's home directory or in the
public shared directory.

5 Accessing Samba from Windows


Now you can access the samba shares from your Windows Desktop. Open the command prompt and
enter "//debian" to open a file explorer:

9 de 12

16/11/2015 23:26

Samba Server Installation on Debian 8 (Jessie)

https://www.howtoforge.com/tutorial/debian-samba-server/

That shows the shares of our samba server.

6 Links
Samba: http://www.samba.org/
Debian: http://www.debian.org/

view as pdf |
Share this page:

10 de 12

Tweet

67

Recommend

65

print

13

16/11/2015 23:26

Samba Server Installation on Debian 8 (Jessie)

https://www.howtoforge.com/tutorial/debian-samba-server/

3 Comment(s)
Add comment
Name *

Email *

I'm not a robot


reCAPTCHA
Privacy - Terms

Comments
From: Raphael at: 2015-08-26 18:10:36

Reply

Perfect work here!!! tks a lot dude!!!


=)
From: jwr at: 2015-10-14 05:52:08

11 de 12

Reply

16/11/2015 23:26

Samba Server Installation on Debian 8 (Jessie)

https://www.howtoforge.com/tutorial/debian-samba-server/

hi,
perfect setup for a tutorial. i would lile to suggest to use sudo apt-get install samba-common-bin
enabeling passwords et cetera.
regards
From: Andrey at: 2015-11-03 11:35:17

Reply

Good tutorial.
But whay you installed additional packages libcups2 and cups if you did't use printing ?

Tutorials

Samba Server Installation on Debian 8 (Jessie)

Xenforo skin by Xenfocus


Howtoforge projektfarm GmbH.

12 de 12

Contact

Help

Imprint

Tutorials

Top
Terms

16/11/2015 23:26

Das könnte Ihnen auch gefallen