This tutorial exists for these OS versions
Code Radio + 24/7 concentration music for programmers jazzy beats from freeCodeCamp.org freeCodeCamp. Jun 13, 2017 - The objective is to perform a basic configuration of Samba server on. Furthermore, for testing purposes it is also recommended to install samba client. 3min 32s ago Docs: man:smbd(8) man:samba(7) man:smb.conf(5).
- Debian 9 (Stretch)
On this page
- 3 Adding Samba Shares
This tutorial explains the installation of a Samba fileserver on Debian 9 (Stretch) 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 Preliminary Note
I'm using a Debian 9 system here with the hostname debian.example.com and the IP address 192.168.1.100. I'll use this minimal Debian system as basis for this tutorial: https://www.howtoforge.com/tutorial/debian-minimal-server/
I will use the nano editor in this tutorial to edit config files on the shell. Nano can be installed with the command:
![Install Install](/uploads/1/2/6/2/126257783/802940204.jpg)
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 to edit the hosts file:
and add a line like this:
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.
Rename 'administrator' user, if exists
My Debian 9 server has a user named 'administrator', this username may cause problems with Samba, so I rename it to 'howtoforge' here. Feel free to use a different name for your user, the name does not matter as long as it is not 'administrator'. Skip this step when your system has no user with the name 'administrator'.
2 Installing Samba
Connect to your server on the shell as root user and install the Samba packages:
Move the current smb.conf file to smb.conf.bak:
And then create a new file smb.conf file:
With the following content:
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:
Then close the Samba configuration file on the server and restart Samba:
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:
At the end of the file /etc/samba/smb.conf add the following lines:
3.1 Group share
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.
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):
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:
Now we restart Samba:
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.
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.
-> Enter the password for the new user.
Now add the user to the Samba user database:
-> 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.100tom 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:
That shows the shares of our samba server.
6 Virtual Machine Image Download of this Tutorial
This tutorial is available as ready to use virtual machine image inovf/ova format that is compatible with VMWare and Virtualbox. The virtual machine image uses the following login details:
SSH / Shell Login
Username: howtoforge
Password: howtoforge
Password: howtoforge
Username: root
Password: howtoforge
Password: howtoforge
Samba Example User Login
Username: tom
Password: howtoforge
Password: howtoforge
The IP of the VM is 192.168.1.100, it can be changed in the file /etc/network/interfaces. Please change all the above passwords to secure the virtual machine.
7 Links
- Samba: http://www.samba.org/
- Debian: http://www.debian.org/
Translation(s): English - 简体中文 ~
Simple Samba file sharing server setup
This is a minimal Samba setup to let other machines access files on a Debian machine.
Install Samba Server
Install Samba Client
Configure the Samba daemon
Edit the Samba configuration file.
In the global section, check the name of the workgroup. It might be useful to know it when you'll try to connect from a Windows machine:
Locate the home share definition:
In that section you may enable read-write access to the home directories:
To share files in some other path on the system, add another share definition such as:
Add Samba users
Samba uses it's own password system so users need to be added by root. Note that the users have to exist in /etc/passwd
You will be prompted for a password for each of those users.
To list existing Samba users:
Restart the Samba daemon
or, if you are using systemd
Try to access the shares (as a normal user)
Try locally first, then from another machine on the network which also installed samba client. When prompted, use the password entered when adding the user to Samba.
To access my share:
![Debian Debian](/uploads/1/2/6/2/126257783/814617585.png)
To access your share:
To access our shared(!) share:
See also
SAMBAClientSetup
CategoryNetworkCategorySoftware