Samba is a suite of open source applications that implements the Server Message Block (SMB) protocol. Many operating systems, including Microsoft Windows, use the SMB protocol for client-server networking. Samba enables Linux / Unix machines to communicate with Windows machines in a network. Samba provides file and print services for various Microsoft Windows clients and can integrate with a Microsoft Windows Server domain, either as a Domain Controller (DC) or as a domain member.
Sharing files is an essential part of server administration. It allows sharing of resources across the network which are needed by users to carry out their tasks. Samba server is usually installed on central Linux server where information is stored in variety of media and accessed using windows client or Linux using Samba client.
In this article, we will be learning how to install and configure samba file sharing on Ubuntu 20.04. Ubuntu 20.04 will be configured as the Samba server then we can access the files with either Windows or Linux clients.
Related Content:
Ensuring that the server is up to date
Before proceeding, let us ensure that our server is up to date and all the packages are the latest version. Use these commands to achieve this:
|
|
If there are packages to upgrade, the above command may take a couple of minutes.
Install Samba packages
The samba packages are available in the default Ubuntu repositories. Install them with this command:
|
|
When prompted to confirm the installation process, typeY
then enter to proceed.
We can check if the installation was successful by running:
|
|
Confirm the installed software package version with this command:
|
|
Configuring Samba shares
The samba configuration file is located in this path /etc/samba/smb.conf
. Before doing any modification, let us create a backup of it so if we mess we have a copy. Use this command in the terminal to create a backup file:
|
|
Next, let us create a directory to be shared.
|
|
Let us now edit the samba config to define the export for the directory we created.
Open the config file:
|
|
Update the configuration in the file to reflect the following:
|
|
Save and close the file.
Verify the configuration using this command:
|
|
You should see something similar to this if all is well.
|
|
Enable Samba service through Firewall
If you have ufw firewall installed and enabled, you need to enable the samba service through firewall. Use this command to achieve that:
|
|
Start and enable the Samba service
The service will not be started by default. Start the service using this command:
|
|
Confirm the service status using this:
|
|
The above output shows that the service has been started successfully. To enable the service on boot, use this command:
|
|
Access the Samba shares with Linux client
To access the file system from a linux client, we need to have the Samba client software installed.
On a Ubuntu Linux, install the software using this command:
|
|
To access the share, this is the format:
|
|
In our client:
|
|
Since we have no password set, just press enter when prompted.
Access Samba shares with Windows Client
In Windows Launch run dialogue in windows by pressing Windows Key + R.
Enter hostname or IP-Address of the server then press Enter Key.
|
|
In my case
|
|
This will open the shares. You can add a file or directory either from samba server or windows client machine to the repository.
Secure Samba share Configuration
Samba allows public access without verification and also private share where one has to be authenticated to access shared resources. In this section, we are going to configure a private directory to shared with samba and accessed using username and password.
Let’s create a Samba user group in our server.
|
|
Create a new user and add it to samba group you just created.
|
|
Create a secure folder then grant it relative permissions and ownership .
|
|
Create password for Samba user we just created that will be used for authentication when accessing the directory.
|
|
Type and retype the password:
|
|
Edit samba configuration file to add secure share configurations.
|
|
Add lines below the command and edit to match your configurations.
|
|
Restart or reload samba services to apply configurations
|
|
Accessing Samba Secure files using Windows Systems
Press Windows Key + R, enter the server hostname or IP address to access the shared folders.
When you open a private folder will prompt for username and password to grant access right to the files.
Access Samba Secure Directory with Linux
To access secure folder, You need to provide a user to the command using this format:
|
|
Enter Samba user password when prompted.
|
|
That is it! We have managed to install and set up Samba for Anonymous and Secure file sharing between our Ubuntu 20.04 Server and other Linux or Desktop Windows clients.