Skip to content

Instantly share code, notes, and snippets.

@Jiab77
Last active November 23, 2018 03:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jiab77/be7de519e13bb33e984a0fa5acac55d5 to your computer and use it in GitHub Desktop.
Save Jiab77/be7de519e13bb33e984a0fa5acac55d5 to your computer and use it in GitHub Desktop.
Samba installation (for ubuntu based distrib)

Samba installation (for ubuntu based distrib)

Just because I'm kind of amnesic and need something somewhere to remember how to install quickly samba on a desktop (or server)

Installation

Simply run this command.

sudo apt install samba samba-common smbclient

Share creation

Once samba is installed, you'll have 2 choices:

  1. Create a new shared folder
  2. Use an existing folder

For the first choice, you can do it that way:

mkdir -pv /path/to/your/folder

Setup

Now you'll have to edit the configuration file /etc/samba/smb.conf with your prefer text editor. In my case I'll use nano.

sudo nano /etc/samba/smb.conf

Feel free to comment all default shares you won't use.

Then add your share like this at the end of the file (change here to fit your needs) :

[share-name]
    comment = Share for VMs
    path = /path/to/your/folder
    browsable = yes
    guest ok = yes
    read only = yes
    create mask = 0700
    directory mask = 0700

I wanted my shared folder to be in read only mode but if you want it writable, you should change to no.

Now, restart the services to apply your changes.

sudo systemctl restart smbd nmbd

Verify your settings

You can use testparm and smbclient to test and verify your settings.

Using testparm

testparm

Using smbclient

Specify your password or press enter if none set.

smbclient -L [host ip]

If everything looks good for you, you may be able to access to your shares remotely from any devices that support the SMB protocol.

Setup your firewall

sudo ufw allow from [network] to any app Samba
sudo ufw status verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment