The simplest file server on Linux. File server for Windows. Regular software updates

To create a terminal, file (FTP) or mail server on Linux, you must be able to work in this operating system. Otherwise it will be difficult to figure it out. The OS does not need a powerful computer. Because it does not waste extra resources on graphic design. Linux distributions can be deployed even on an old PC. Therefore, Linux or Ubuntu Server is often used to create various servers.

An appropriate script, which you can easily create yourself, should contain the following code for this purpose. Use this entry to ensure that the script runs and, if logged in successfully, responds to a notification email to the required address. The prerequisite is that the script is given permission 755, which is achieved with the following command.

Disabling unused ports

Open ports generally do not pose much of a security risk. If you were able to implement a minimal system installation and access a small number of third-party applications, the number of other ports needed is manageable. For risk, these open interfaces will only be used if the react programs have security holes, and criminals will take advantage of this fact. As the number of applications increases, this dangerous potential grows.

A lot of different literature has been written about this. Some books about Linux are a thousand pages long. You will have to work through the terminal and enter all commands manually. But you can still make a small Linux server with your own hands, which will include file storage, Web services and a mail protocol.

Ubuntu Server is based on the Linux operating system. It does not require a modern processor, a good video card or a large amount of RAM to work. With Linux, you can deploy a server even on an old laptop. And it will have all the necessary components: mail, FTP, Web.

Regular software updates

For this reason, it is useful to protect your server from such attacks by blocking all unused open ports. You can use this tool to create fixed traffic throttling rules, including defining desired or undesired ports. As a rule, there is no software without the vulnerabilities mentioned in the previous section. However, exploitable malware must first be detected by cybercriminals before they can attack. Typically, known vulnerabilities are closed again through published updates in a very short time.

You can download a Linux disk image from the Ubuntu.ru website. Choose any version with Server (not Desktop!). The download will take place through a Torrent client. This image must be written to a disc or flash drive (using LiveUSB). You can also use a virtual drive.

Ubuntu has a simplified interface. There are no graphic excesses in it. This OS is perfect for making a DIY Linux server. With it, computer resources will be used for the needs of the domain. After all, she needs very little to work.

If you stay up to date with updates to your operating system and installed programs, and make new updates promptly, you can ensure your server is best protected. Almost all server systems also allow you to automatically download and install important security updates in the background.

This is how you configure when and how you regularly check for updates, whether you want installed updates to be installed, and when the system should reboot. Other scripts such as automatic updates will then be used to install automatically. Make sure you have an updated update process that allows you to keep up to date with updates. This allows you to better understand and correct errors that occur as a result of the update process.

Its installation goes like this:

  • Select the language and region you live in.
  • Create an administrator name. It is used to manage the server.
  • Also enter a username in the “Username for your account” field. Under this account you will communicate with Ubuntu technical support.

Hackers who want to gain access to your server or the applications running on them have fundamentally different options. One of the simplest and most commonly used types of attack is the so-called brute force method. The attacker tries to gain access to the passwords using a tool that attempts to log into the system one at a time. However, the more careful you are when assigning your passwords, the more unlikely it is that this method will succeed. In particular, if you offer a service with a subscription mechanism, you must assume that not every user is as conscientious and careful as necessary.

Specifying the username in Ubuntu

  • Enter password. Confirm it.


  • Specify the domain if you have one. It will contain all services: file (FTP), email, website hosting, and so on.
  • Wait while the system installs.
  • After that, she will offer additional components.

Here is a list of what is needed for a Linux server and its full operation:

Of course, there is no need for complex, expensive software to protect against such attacks. Since every login attempt is logged, responded to, and written to log files, simple analysis tools can help. You can individually set the number of attempts to block the lock or how long it should be valid.

Set up your server securely: install monitoring tools from the start

You can also take it a step further and set up two-factor authentication to establish a connection to your server to further secure your login. If you want to protect the server, the listed measures against external adversities are not of great importance. However, it is equally important to ensure that the interaction between hardware and software functions as desired. This is by no means a one-time thing that ends once your server environment has successfully launched, but a long-term task that you should never lose sight of.

  • Open SSh. Used for remote administration. This will come in handy if you decide to manage the service from another computer. Then on a Linux PC you can disable the monitor and video adapter.
  • LAMP. A set of Linux utilities that includes Apache (Web server). MySQL (database) and PHP (programming language for CMS). These components are needed to create a control interface.
  • Samba file server. Allows you to configure file sharing between computers. If you need an FTP server, select this option.
  • Virtual Machine host. Install if you are going to use virtualization capabilities.
  • Print server. Network printers.
  • DNS server. Domain Name System. With it you can recognize the IP address by the computer name and vice versa.
  • Mail server. Mail server.
  • PostgreSQL database. Object-relational databases.

Select what you need and confirm installation. When you first start, you will need to enter your administrator login and password. The console will open. It is similar to the Windows command line or the MS DOS operating system interface.

With so many different system processes this is of course easier said than done, so you should have access to help tools from the start that monitor all activity on your server and alert you to any incidents.

Trust is good, backups are better

Once launched, the open application selectively monitors processes, files, clouds, hosts, programs or scripts. It is, however, somewhat more complex, but in the main version it is also open source and can be extended with various plugins. With configuration recommendations, you significantly increase the level of server security. However, even the best configuration cannot provide 100% server protection.


Initially, you will need to check for updates. Type the command “Sudo apt-get update” or “Sudo apt-get upgrade” without the quotes. After the update, you can start setting up all server components: FTP, mail, Web.

There is a pseudo-graphical interface for Ubuntu - Midnight Commander. This is an analogue of the Norton Commander shell, which was developed for the MS DOS system. It’s easier to work with such an interface - everything is clearer than in the console.

Program errors, hardware failures or personal negligence can lead to data loss in the worst case scenario. For server operators, the security aspect plays a decisive role. For those developing and implementing a comprehensive defense concept, prepare for emergencies. Apart from classic measures such as security software, backup, password protection and encryption, there are also some useful tools and frameworks that can support them in the fight against intruders.

Chapter 26: Restoring Access

Chapter 28: Seminar Data Backup Topics

Chapter 30: Network Network Routing. The first entry is used for dial-up lines. It works with the following data. When we open it, we will write the following line. Once completed, launch the application from the same console by typing.

Launching the Linux Terminal

Modern Linux uses a terminal instead of a console. To enter it:

  1. Open Applications.
  2. Click "Standards".
  3. There will be a "Terminal" there.


You can enter commands into it just like in Ubuntu Server.

We already have a server installed! Let's write it in the console. With this we have finished all the work, we can now create our own web pages, it is important that you have a good editor that is convenient to program. We can call a server for all computers connected to the network and provide different services to users. To do this, we need enough to create a computer that can satisfy our needs. We can install a server that offers web services, files and printing.

Chapter 11: Setting Up a Read-Only File Server

11.1. Creating a shared directory

Let's start working with the Samba server by setting up a simple file server with read-only access. Every client (even anonymous clients using guest access) will be able to read the contents of shared files.

The first step is to create a directory and place several test files in it.

# mkdir -p /srv/samba/readonly # cd /srv/samba/readonly/ # echo "It's cold today." >winter.txt # echo "It's hot today." >summer.txt # ls -l total 8 -rw-r—r— 1 root root 17 Jan 21 05:49 summer.txt -rw-r—r— 1 root root 18 Jan 21 05:49 winter.txt #

11.2. Configuring shared directory settings

11.2.1. Section of global parameters of the smb.conf configuration file

In this example, the Samba server is in a workgroup named WORKGROUP (which is a standard workgroup). We also specify a server description string that can be seen by users exploring the network using the net view command, Windows Explorer, or the smbclient utility.

# head -5 smb.conf workgroup = WORKGROUP server string = Public Anonymous File Server netbios name = TEACHER0 security = share

You may have noticed a line in the above section of the server configuration file. This line sets the standard mode for restricting access to our Samba server. Setting the access mode allows clients (which can be the smbclient utility, any version of Windows OS, another Samba server) to provide a password to access each of the shared resources. This is one of the options for using the SMB/CIFS protocol. Another use of this protocol (called user mode) allows the client to provide a username and password combination before the server obtains information about the share the client wishes to access.

11.2.2. Section of shared resource settings of the smb.conf configuration file

Our shared resource will be named pubread, and the path to the previously created directory will be used as the path (specified using the path parameter). Each user will be able to access this directory (through the use of the parameter value) read-only (according to the parameter value).

Path = /srv/samba/readonly comment = files to read read only = yes guest ok = yes

Below is a very similar configuration used by the Samba server included with the Ubuntu 11.10 distribution.

root@ubu1110:~# cat /etc/samba/smb.conf workgroup = LINUXTR netbios name = UBU1110 security = share path = /srv/samba/readonly read only = yes guest ok = yes

In fact, the name of the Linux distribution you use is not critical. Below is a similar configuration used by the Samba server included in the Debian 6 distribution, which is essentially identical to the one above.

root@debian6:~# cat /etc/samba/smb.conf workgroup = LINUXTR netbios name = DEBIAN6 security = share path = /srv/samba/readonly read only = yes guest ok = yes

11.3. Restarting the server

After testing the configuration file using the utility, you should restart the Samba server (so that you do not have to wait for information about the shared resource to begin distributing between computers on the network).

# service smb restart Shutting down SMB services: [ OK ] Shutting down NMB services: [ OK ] Starting SMB services: [ OK ] Starting NMB services: [ OK ]

11.4. Checking the presence of a shared resource

11.4.1. Checking using the smbclient utility

Now you can check the availability of a shared resource using the utility. Our share is the fourth share in the list.

# smbclient -NL 127.0.0.1 Domain= OS= Server= Sharename Type Comment ——— —- ——- IPC$ IPC IPC Service (Public Anonymous File Server) global$ Disk pub0 Disk pubread Disk files to read Domain= OS= Server= Server Comment ——— — —- TEACHER0 Samba 3.0.33-3.7.el5 W2003EE Workgroup Master ——— ——- WORKGROUP W2003EE

11.4.2. Check using Windows OS

The last step in checking for the presence of a shared resource is to read the file from the Samba shared directory using a computer running Microsoft Windows. First of all, we must use the command to mount the pubread shared directory as a disk drive, denoted by the letter K:.

C:\> net use K:\\teacher0\pubread The command completed successfully.

After this, we must check the ability to view the contents of the shared directory and read files from this directory.

C:\> dir k: Volume in drive K is pubread Volume Serial Number is 0C82-11F2 Directory of K:\ 01/21/2009 05:49

. 21/01/2009 05:49 .. 01/21/2009 05:49 17 summer.txt 01/21/2009 05:49 18 winter.txt 2 File(s) 35 bytes 2 Dir(s) 13.496.242.176 bytes free

In order to simply make sure that it is safe to use a Samba server to organize file sharing, let's try to write data to a file from a directory shared with it.

K:\> echo very cold > winter.txt Access is denied. K:\>

Or, you can use Windows Explorer.

11.5. Note about using netcat utility

The above Windows shell output was obtained in the Linux console using a utility to interact with the Windows command shell.

This utility works quite simply: it waits for a connection to a specific port of a computer running Windows OS, and executes the command shell binary file cmd.exe after receiving the connection. The netcat utility is similar to the cat utility in the sense that, like the cat utility, it does nothing other than transfer data, but the netcat utility is designed to transfer data over a network.

To create the conditions necessary to establish the described connection, you should run the following command on a computer running Windows OS (after downloading the Windows version of the netcat utility).

nc -l -p 23 -t -e cmd.exe

After this, you can establish a connection to this machine using the netcat utility from any computer running Linux. This will display the cmd.exe shell greeting in your Linux shell.

paul@laika:~$ nc 192.168.1.38 23 Microsoft Windows (C) Copyright 1985-2003 Microsoft Corp.

Setting up a corporate file server on Debian Linux

C:\> net use k: /delete net use k: /delete k: was deleted successfully.

11.6. Practice: Setting up a file server with read-only access

11.7. The correct procedure for completing a practical task: setting up a file server with read-only access

1. Create a directory to allow each client on the network to have read-only access to its files in a suitable file system directory (following the standard FHS file system hierarchy).

Select one of the following options:

The directory must not be used!

The directory should not be used either!

The directory is also not suitable!

2. Make sure that you have set the correct owner ID for the created directory and that the files in it are public.

chown root:root /srv/samba/readonly chmod 755 /srv/samba/readonly

3. Place the text file in the created directory.

echo Hello World > hello.txt

4. Provide all clients with access to the created directory over the network using the Samba server.

Your Samba server configuration file smb.conf.readonly might look like this:

Workgroup = WORKGROUP server string = Read Only File Server netbios name = STUDENTx security = share path = /srv/samba/readonly comment = read only file share read only = yes guest ok = yes

Test its correctness using the testparm utility before use!

5. Check from your computer and a separate computer (using the smbclient, net use, commands) the readability of files from the shared directory.

If using Linux:

If using Windows Explorer: Go to the My Network Neighborhood directory.

If you are using the Windows command shell

6. Create a backup copy of your smb.conf server configuration file named smb.conf.ReadOnlyFileServer.

cp smb.conf smb.conf.ReadOnlyFileServer

If you liked the article, share it with your friends:

Samba- a program that allows you to access network drives on various operating systems using the SMB/CIFS protocol. It has client and server parts. It is free software, released under the GPL license.

Samba runs on most Unix-like systems such as GNU/Linux, POSIX-compliant Solaris and Mac X Server, various BSD variants, /2, Windows. Samba included in almost all GNU/Linux distributions, including, of course, Ubuntu.

To make a shared folder in Ubuntu Desktop, just right-click on the folder and select the “Publish Folder” menu item. There is no need to edit any configuration files. Everything described below applies only to manual configuration, for example, in the case of creating a file server.

To install, just open a terminal and enter:

sudo apt-get install samba

The application will be automatically downloaded and installed.

Using the terminal, we will make a backup copy of the initial configuration file:

sudo cp /etc/samba/smb.conf(,.bak)

Now you can edit the settings file /etc/samba/smb.conf; to do this, open it in any text editor with superuser rights. For example, like this:

sudo nano /etc/samba/smb.conf

— what is written below is generally speaking just one specific scenario for using Samba, and in a huge number of cases everything is configured absolutely wrong. The article needs to be corrected, focusing on the capabilities of Samba, and not just on the use of this program as a file storage with local authorization. It is better to include the example with file storage in a separate detailed article.

An example of setting up Samba as a standalone file server with authorization:

; Global server settings; General server settings; Computer name that will be displayed in the network environment netbios name = main-server server string = ; Client workgroup workgroup = WORKGROUP announce version = 5.0 socket options = TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192 passdb backend = tdbsam security = user null passwords = true ; File for user name aliases username map = /etc/samba/smbusers name resolve order = hosts wins bcast ; wins support is set to yes if your nmbd(8) in Samba is a WINS server. Do not set this parameter to yes unless you have multiple subnets and do not want your nmbd to act as a WINS server. Never set this parameter to yes on more than one machine within the same subnet. wins support = no ; Printer support printing = CUPS printcap name = CUPS ; Logs log file = /var/log/samba/log.%m syslog = 0 syslog only = no ; Configuring binding to which interfaces to listen on, if listens on all interfaces are not specified; interfaces = lo, eth0 ; bind interfaces only = true ; ; ; path = /var/lib/samba/printers ; browseable = yes ; guest ok = yes ; read only = yes ; write list = root ; create mask = 0664 ; directory mask = 0775 ; ; ; path = /tmp ; printable = yes ; guest ok = yes ; browseable = no ; ; ;path = /media/cdrom ;browseable = yes ;read only = yes ;guest ok = yes ; Hard drive ball; The name of the balls is visible from clients; Path to the shared disk path = /media/sda1 ; Is it possible to browse browseable = yes read only = no guest ok = no create mask = 0644 directory mask = 0755 ; Binding to a specific user name or group, names separated by a space; force user = user1 user2 ; force group = group1 group2 ; Another hard drive, similar to the one above path = /media/sde1 browseable = yes read only = no guest ok = no create mask = 0644 directory mask = 0755

Now we need to deal with the users.

Samba uses users that are already in the system, let’s take the name user as an example, let’s say that it is already in the system, we need to add it to the SMB database and assign a password to access shared resources, we’ll do this with the command:

smbpasswd -a user

You will be prompted to enter a password, the user will be added to the database, now you need to enable this user.

smbpasswd -e user

Next, let's create an alias for the username user to make it easier for us to access from a Windows machine on which we have, for example, a user named Admin. To do this, we'll create and edit the file /etc/samba/smbusers:

sudo touch /etc/samba/smbusers sudo gedit /etc/samba/smbusers

Write a couple of lines into the file

# Unix_name = SMB_name1 SMB_name2 user = Admin

This completes the setup, restart Samba.

For Ubuntu 10.04 version use the command:

sudo service smbd restart

For earlier versions use:

sudo /etc/init.d/samba restart

Now you can use shared resources.

Setting up a Samba server on Ubuntu

Customization apps

There are also applications that allow you to configure Samba through a graphical interface (see GUI applications for working with Samba).

You can install the simplest one for Samba with the command:

sudo apt-get install system-config-samba

It is launched with the command:

sudo system-config-samba

It writes all changes to the samba configuration file.

For remote administration of Samba, webmin is perfect as a web interface for Samba.

File server for Windows network

Very often Samba is used to create a file server on a Windows network. A separate article is devoted to a description of this use case:

Articles about Samba

Links

Opening Windows to a Wider World. (slogan on www.samba.org)

Samba - implementation of network protocols Server Message Block (SMB) And Common Internet File System (CIFS). The main purpose is to share files and printers between Linux and Windows systems.

Samba consists of several daemons that run in the background and provide services and a number of command line tools for interacting with Windows services:

  • smbd- a daemon that is an SMB server for file services and print services;
  • nmbd- a daemon that provides NetBIOS naming services;
  • smblient— the utility provides command line access to SMB resources. It also allows you to get lists of shared resources on remote servers and view your network environment;
  • smb.conf— a configuration file containing settings for all Samba tools;

List of ports used by Samba

An introductory article about the basic principles of sharing files and printers.

Server installation and configuration

# under Arch Linux, server yaourt -S samba # under Arch Linux, client yaourt -S smbclient # under Ubuntu, server sudo apt-get install samba samba-common system-config-samba

Copy the settings file smb.conf

sudo cp /etc/samba/smb.conf.default /etc/samba/smb.conf

By default they are created resources for user home directories (section homes V smb.conf) and printers (section printers).

Access to the resource can be password-based or anonymous. For the first method there are a couple of points:

  1. the user must exist in the system (created using the command and set a password);
  2. the user must be added as a Samba user (using the command);

View users

sudo pdbedit -L -v

It is necessary that the computers belong to the same workgroup, in Windows this is the default WORKGROUP, so we will use it.

Below is an example of a simple file smb.conf with settings for anonymous access to the directory /srv/samba/public.

sudo mkdir -p /srv/samba/public sudo chmod -R 0777 /srv/samba/public

Parameter names are not case sensitive. There are synonyms for some common parameters, and antonyms for others. For example, writable And writeable are synonyms, and read only– an antonym for them, i.e. option read only = yes is equivalent to option writable = no.

Workgroup = WORKGROUP server string = Samba Server log file = /var/log/samba/%m.log max log size = 50 security = user map to guest = Bad User dns proxy = no # follow symlinks unix extensions = no wide links = yes follow symlinks = yes # utf encoding dos charset = cp866 unix charset = UTF8 # disable printers load printers = no show add printer wizard = no printcap name = /dev/null disable spoolss = yes # hosts allow = 127. 192.168.24 . # by default, all files starting with a dot will have the “hidden” attribute hide dot files = yes comment = public folder path = /home/proft/public read only = no locking = no browsable = yes # allow guest access guest ok = yes force user = nobody force group = nobody # guest only = yes # create mode = 0777 # directory mode = 0777 # allow access only user1, user2 # valid users = user1, user2

Let's check the correctness of the settings using the command

The option specifies to also display default values.

Let's start the Samba server

# under Arch Linux sudo systemctl start smbd # under Ubuntu, server sudo service start smbd

Let's check the connection to Samba per port 139 by using

telnet 192.168.24.100 139

Samba has a number of options related to user authentication. The most important of them is the parameter security, which can take five different values

One of the most standard ways to communicate over a network between Ubuntu and Windows computers is to set up Samba as a file server. This chapter explains how to set up a Samba server to share files with Windows clients.

The server will be configured to allow any client on the network to access files without requiring a password. If your environment requires more stringent access control, see Securing Samba Servers.

Installation

Settings

The main Samba configuration file is /etc/samba/smb.conf. The initial configuration file has a significant number of comments to document the various configuration directives.

Not all possible options are included in the default settings file. See manual man smb.conf or Samba FAQ for more details.

1. First change the following key/value pairs in the section file /etc/samba/smb.conf:

Workgroup = EXAMPLE ... security = user

Parameter security is located much lower in the section and is commented out by default. Also replace EXAMPLE to something more appropriate to your surroundings.

2. Create a new section at the end of the file or uncomment one of the examples for the directory that you want to share:

Comment = Ubuntu File Server Share path = /srv/samba/share browsable = yes guest ok = yes read only = no create mask = 0755

    comment: A short description of the shared resource. Used for your convenience.

    path: path to the shared directory.

    This example uses /srv/samba/sharename because, according to the File System Hierarchy Standard (FHS), the /srv directory is where all data related to a given site should reside. Technically, a Samba share can be placed anywhere on the file system where file access restrictions allow, but following standards is recommended.

    browsable: Allows Windows clients to view the contents of a shared directory using Windows Explorer.

    guest ok: Allows clients to connect to the shared resource without providing a password.

    read only: Determines whether the resource is accessible with read-only or write privileges. Write privileges are only available when you specify no, as shown in this example. If the value yes, then access to the resource will be read-only.

    create mask: Defines what access rights will be set for new files created.

3. Now that Samba is configured, you need to create a directory and set permissions on it. Enter in terminal:

Sudo mkdir -p /srv/samba/share sudo chown nobody.nogroup /srv/samba/share/

parameter -p tells mkdir to create a complete directory tree if it doesn't exist.

4. Finally, restart samba services to apply the new settings:

Sudo restart smbd sudo restart nmbd

Again: This configuration allows full access to any client on the local network. For a more secure setup, see the section Securing Samba Servers.

You can now search the Ubuntu file server using the Windows client and browse its shared directories. If your client does not show your shares automatically, try accessing your server by its IP address, for example, \\192.168.1.1, from a Windows Explorer window. To check that everything works, try creating a directory inside your share from Windows.

To create additional shares, create a new section in /etc/samba/smb.conf and restart Samba. Just make sure the shared directory is created and has the correct permissions.

Shared resource «» and the way /srv/samba/share- these are just examples. Set the resource name and directory name according to your environment. It is a good idea to use the name of the resource's directory on the file system as the name of the resource. In other words, the resource can be specified for the /srv/samba/qa directory.

In this tutorial we are going to learn how to install and configure Samba server on Ubuntu 16.04. Samba is a free and open source implementation of the SMB/CIFS protocol for Unix and Linux that allows file and printer communication on Unix/ and Windows machines on a local network.

Samba is a software package, the two most important of which are:

  • smbd: Provides SMB/CIFS service (file and print sharing) and can also act as a Windows domain controller.
  • nmbd: Provides NetBIOS naming service

How to install Samba server on Ubuntu 16.04

Samba is included with most Linux distributions. To install Samba on , simply run:

Sudo apt install samba

Latest stable version available is 4.5.3, released on December 19, 2016. To check the version Samba , run

Sudo smbstatus

Sudo smbd --version

Example output:

Samba version 4.3.11-Ubuntu

To check if the Samba service is running, run the following commands.

Systemctl status smbd systemctl status nmbd

To start these two services, run the following commands:

Sudo systemctl start smbd sudo systemctl start nmbd

After launch, smbd will listen on port 139 and 445.

Editing a Configuration File

There's only one configuration file that needs to be edited: /etc/samba/smb.conf.

Sudo nano /etc/samba/smb.conf

In the section, make sure the value workgroup belong to a workgroup of Windows computers.

Workgroup = WORKGROUP

Scroll down to the bottom of the file. (In the nano text editor, press CTRL+W and then CTRL+V .) Include a new section as shown below. Replace username with the desired username.

Comment = Home Public Folder path = /home/username/ writable = yes valid users = username

Home Share is the name of the folder that will be displayed on the Windows network. A comment is a description of the shared folder. The next 3 lines indicate that only the specified user, valid users, has access to the /home/username/ directory, which is also writable. The above configuration will disable anonymous access.

Save and close the file, and then run the following command to check if there are syntax errors.

Testparm

Creating a user

Samba contains a default user as a security mode, meaning that clients must enter a username and password to access the shared folder. To add a user in Ubuntu, run the following command:

Sudo adduser username

You will be prompted to set a Unix password. Additionally, you need to set a separate Samba password for the user using the following command:

Sudo smbpasswd -a username

Now all that's left to do is restart the smbd daemon.

Sudo systemctl restart smbd

Samba access to shared folder from Windows

On a Windows computer that is on the same network, open File Explorer and click Network in the left pane. You will see a samba server. Double-click the shared folder and enter your username and password.

Samba access to share folder from Ubuntu computer

In File Manager, go to the Network tab in the left pane and select Windows Network.

Select the workgroup, Samba server, and shared folder, and then enter the Samba username and password.

Adding multiple users or groups

If multiple accounts need to gain access to a shared folder, then the authorized users must be changed, as shown below in the /etc/samba/smb.conf file.

Valid users = user1, user2, user3

Also use smbpasswd to set a Samba password for each of these users.

Sudo smbpasswd -a user1 sudo smbpasswd -a user2 sudo smbpasswd -a user3

To allow a group of users to access a shared folder, use the following configuration in /etc/samba/smb.conf.

Valid users = @sambashara

Create a group.

Sudo groupadd sambashare

Then add users to this group

Sudo gpasswd -a user1 sambashare sudo gpasswd -a user2 sambashare sudo gpasswd -a user3 sambashare

The group must have write permission to the shared folder, which can be achieved with the following two commands.

Set sambashare as the group owner of the shared folder:

Sudo chgrp sambashare /path/to/shared/folder -R

Grant write permission to the group.

Sudo chmod g+w /path/to/shared/folder/ -R

I hope this article helped you set up a Samba server on Ubuntu 16.04. As always, if you found this post helpful, please leave a comment.