Install Samba on Ubuntu (on an RPi 2)

Note: The RPi2 with officially supported Ubuntu is proving problematic, I want to move to something more reliable.

After installing Ubuntu on my RPi, I’ll now install Samba. This will allow USB drives attached to the RPi to be accessed by other computers, making the RPi into a NAS device.

  1. Install Samba:
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install samba
  2. Duplicate original samba settings:
    sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old

  3. Add Samba user:
    sudo useradd Joe --shell /bin/false
  4. Add user password:
    sudo smbpasswd -a Joe
  5. Change samba config file using nano text editor:
    sudo nano /etc/samba/smb.conf

    Added Under Authentication:

    security = user
    encrypt passwords = yes

    #commented out printer stuff,
    added to bottom:

    [Data]
    path = /media/Data
    available = yes
    valid users = smbuser
    read only = no
    browseable = no
    public = no
    writable = yes
  6. Restart samba
    sudo /etc/init.d/samba restart
  7. Step 4 in these instructions shows how to mount a drive, this can be used in place of
    path = /media/Data

    in step 5 (on this page).

    Note: Make sure the shared path has appropriate Linux permissions for samba to be able to access it

  8. allow SMB ports through ufw firewall:
    sudo ufw allow proto udp from 192.168.1.0/24 to any port 137
    
    sudo ufw allow proto udp from 192.168.1.0/24 to any port 138
    
    sudo ufw allow proto tcp from 192.168.1.0/24 to any port 139
    
    sudo ufw allow proto tcp from 192.168.1.0/24 to any port 445

1 thought on “Install Samba on Ubuntu (on an RPi 2)”

Leave a Reply

Your email address will not be published. Required fields are marked *