Setting Up Raspberry Pi with Cockpit and File Sharing via Samba

O

Ohidur Rahman Bappy

MAR 22, 2025

Setting Up Raspberry Pi with Cockpit and File Sharing via Samba

Update Raspberry Pi

Update and upgrade your Raspberry Pi to ensure you have the latest packages:

sudo apt update
sudo apt upgrade

Create a Password for the User

Set a password for the default user:

sudo passwd ubuntu

List All Interfaces

Check available network interfaces:

ls /sys/class/net

Add WiFi Configuration

Ensure tabs are correctly aligned; otherwise, the configuration will not work.

Edit the network configuration:

sudo nano /etc/netplan/50-cloud-init.yaml

Add your WiFi details:

network:
    ethernets:
        eth0:
            dhcp4: true
            optional: true
    version: 2
    wifis:
        wlan0:
            dhcp4: true
            optional: true
            access-points:
                "SSID_name":
                    password: "WiFi_password"

Generate and apply the configuration:

sudo netplan generate
sudo netplan apply
sudo systemctl start wpa_supplicant

Install Cockpit

Cockpit provides a web-based interface for managing your Raspberry Pi:

sudo apt install cockpit

Alternatively, you can install from backports:

. /etc/os-release
sudo apt install -t ${VERSION_CODENAME}-backports cockpit

Install Samba

Samba allows you to share files over a network:

sudo apt install samba cifs-utils
sudo nano /etc/samba/smb.conf

Add the following lines to configure the shared folder:

[SharedFolder]
  comment = My Shared Folder
  path = /home/ubuntu/shared
  read only = no
  browseable = yes

Restart Samba to apply the changes:

/etc/init.d/smbd restart

Create a shared directory:

sudo mkdir /home/ubuntu/shared

Set permissions for the shared directory:

sudo chmod 0777 /home/ubuntu/shared
sudo chown ubuntu:ubuntu /home/ubuntu/shared

Update the firewall rules to allow Samba traffic:

sudo ufw allow samba

Windows Configuration

Modify the registry to allow accessing the shared folder:

Open regedit and navigate to:

Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters

Set AllowInsecureGuestAuth to 1.

Access the shared folder by typing in Run:

\\<your-ip-address-to-ubuntu>\<your-share-folder>

Now, you can see the shared files. Congratulations! You have successfully set up file sharing on your Raspberry Pi.