Search
K
Links

Configure and access shared folders on Linux

Learn how to configure shared folders and access them on Linux over Meshnet.
In this article, you will learn how to configure a new network share and access a folder shared from another device using Debian-based Linux distributions.
Note
For this procedure, Ubuntu 22.04.1 LTS is used as an example.

Configure a network share

For the purpose of this guide, we will be using the Samba suite of applications, which provides access to SMB/CIF protocols.

Prerequisites

Before you start the sharing process, be sure to complete the following steps to prepare your system:
  1. 1.
    Update all of your repositories and install Samba by running the following command in the terminal:
    sudo apt update && sudo apt install samba -y
  2. 2.
    Change permissions for the /home/$USER directory to allow access by running this command:
    sudo chmod 755 /home/$USER

Set up a shared folder

Depending on your system, you may opt to configure a shared folder using the operating system's file manager or by using the command line.
GUI
Terminal
To create a network share using a file manager's network-sharing options:
  1. 1.
    Open Files and navigate to the folder you wish to share.
  2. 2.
    Right-click the folder, select Properties, and click Local network share.
  3. 3.
    Select Share this folder, and enter the name for your network share.
  4. 4.
    Select Guest access to allow passwordless access to the shared folder.
  5. 5.
    Click Create share.
    Local network share settings of a folder
Take the following steps to complete the shared folder configuration using the command line:
  1. 1.
    Open the terminal.
  2. 2.
    Navigate to the folder that you want to share and print out its full path by using the pwd command.
    Example
    /home/ubuntu/Desktop/MeshnetFolder
    Output of 'pwd' command
  3. 3.
    Run the following command to open the Samba configuration file using the Nano text editor:
    sudo nano /etc/samba/smb.conf
  4. 4.
    At the end of the file, add the following information where <name> is a specific name for your network share and </path/to/folder> is the full path from Step 2:
    [<name>]
    path = </path/to/folder>
    browsable = yes
    writable = yes
    guest ok = yes
    guest only = yes
    The complete configuration in the smb.conf file for MeshnetFolder would be:
    Edited 'smb.conf' file
  5. 5.
    Press Ctrl + X, Y, and Enter to save changes and exit.
  6. 6.
    Run the following command to restart the Samba daemon process:
    sudo systemctl restart smbd

Access shared folders

Most Linux file managers let you directly access files shared on other devices. In this example, you will learn how to access a network share using GNOME Files.
  1. 1.
    Run the nordvpn meshnet peer list command, and copy the Nord name of the peer you wish to reach.
  2. 2.
    Open GNOME Files and select Other locations in the sidebar.
  3. 3.
    In the Connect to server field, enter smb://, paste the Nord name followed by a slash (/) and the name of the network share, and click Connect. Example
    smb://secret.meerkat-everest.nord/MeshnetFolder
    Connecting to a shared folder
  4. 4.
    Select Anonymous or Registered user, depending on the folder’s configuration. Click Connect.
    Authentication screen

Mount a network share

Once you restart your machine, the network share that you connected to will become unavailable. To access it again, follow the steps outlined in the Access shared folders section. However, you can mount the shared folder directly onto your operating system for convenient access whenever you need it. On Linux, you can achieve this by using CIFS.

Prepare a mounting point

  1. 1.
    Open the terminal.
  2. 2.
    Update all of your repositories and install the CIFS tool by entering the following:
    sudo apt update && sudo apt install cifs-utils -y
  3. 3.
    Create a new directory using the mkdir command, where the network share will be mounted. Example
    mkdir MeshnetFolder
  4. 4.
    Navigate to the newly created folder using the cd command and print out its full path using the pwd command.
    Ouput of 'pwd' command
  5. 5.
    Check your user ID by executing this command:
    echo $UID

Edit the file system table

  1. 1.
    Open the fstab file with root privileges using the Nano text editor by running this command:
    sudo nano /etc/fstab
  2. 2.
    At the end of the file, add a line for the network share.
    For guest access:
    //<NordName>/<ShareName> </path/to/folder> cifs guest,uid=<UID>,iocharset=utf8 0 0
    For access with username and password authentication:
    //<NordName>/<ShareName> </path/to/folder> cifs username=<USERNAME>,password=<PASSWORD>,uid=<UID>,iocharset=utf8 0 0
    Where:
    • <NordName> is the Nord name or the Meshnet IP of the host device.
    • <ShareName> is the name of the network share you are trying to access
    • </path/to/folder> is the path to the mounting point from Step 4 of the Prepare a mounting point section.
    • <USERNAME> and <PASSWORD> are the authentication details for accessing the network share.
    • <UID> is the user ID from Step 5 of the Prepare a mounting point section.
      Example
      //secret.meerkat-everest.nord/MeshnetFolder /home/ubuntu/MeshnetFolder cifs guest,uid=1000,iocharset=utf8 0 0
  3. 3.
    Press Ctrl + X, Y, and Enter to save changes and exit.
  4. 4.
    Run the following command to mount the network share:
    sudo mount -a

See also

© 2023 Nord Security. All Rights Reserved.