1. Academy
  2. Compute & Instances

How to create a SMB file server

In this tutorial you will learn how to setup a file server using Samba.

Prerequisites

For this tutorial you need the following:

Step 1 - Create a new security group

  1. Login to your Fuga account
  2. Select Network > Security Groups
  3. Click on ‘Create security group’
  4. Name your security group Samba
  5. Click on ‘Add rule’
  6. Select the option ‘Port’ under heading ‘Open Port’ 
  7. Type the port number ‘455’
  8. Click on ‘Create rule’.

Step 2 - Create a new instance

  1. Select Compute > Instances
  2. Click on ‘Create instance’
  3. Under ‘Boot Source’ select the distro ‘Ubuntu 20.04 LTS’
  4. Choose between ‘Boot disk’ Ephemeral or Volume
  1. Choose a Flavor
  2. Select as network ‘public’
  3. Select your own 'Key pair'
  4. Under heading Security Groups, select ‘default’ and ‘Samba’
  5. Give your instance a name
  6. Click on ‘Launch instance’ for deployment.

Step 3 - Install Samba

Login to your server with SSH:

$ ssh ubuntu@<IP_ADDRESS>

First update and upgrade your server:

$ sudo apt update && upgrade -y

After updating, install Samba: 

$ sudo apt install samba

You can check if the installation was successfully, by using this: 

$ samba

Output should be:

samba version 4.13.17-Ubuntu started.
Copyright Andrew Tridgell and the Samba Team 1992-2020

Step 4 - Setting up Samba

Now samba is installed, lets make a (new) directory for you to share:

$ mkdir /sambashare/

Edit the smb.conf  file:

$ sudo vi /etc/samba/smb.conf

At the bottom of the file, paste the lines below in your smb.conf:

[sambashare]
comment = Samba
path = /home/ubuntu/sambashare
read only = no
browsable = yes

Exit the file by hitting esc and type wq to save.

You have configured the smb.conf  file, to save and restart Samba, you use the following command:

$ sudo service smbd restart

Allow Samba traffic in your firewall:

$ sudo ufw allow samba

Step 5 - Create a new user on the SMB file server.

Create a new user:

$ sudo useradd <username>

Give the new user a (secure) password:

$ sudo smbpasswd -a <username>

You will get the following output to enter a new password:

New SMB password:
Retype new SMB password:
Added user <user>.

Step 6 - connect to the SMB files.

To login with MacOS, go to finder, click on Go > Connect to Server.
Type the following to connect with the SMB file server: 

smb://<IP-ADDRESS/sambashare

To login with Linux, open the default file manager and click connect to server.
Type the following to connect with the SMB file server:

smb://<IP-ADDRESS/sambashare

To login with Windows. open the File Manager and edit the file path with the following:

\\<IP-ADDRESS\sambashare

Conclusion.

In this tutorial, you have setup your own SMB file server using Samba and you created a new directory that users can approach.