Install samba package
sudo apt-get install samba
Samba configuration file is located in /etc/samba/smb.conf
sudo nano /etc/samba/smb.conf
Add the following
workgroup = YourDomainName (in CAPITAL LETTERS)
security = user
Enter the following [Public] READ ONLY share setting at the end
[Public]
comment = Read only
path =/srv/samba/share
browsable = yes
guest ok = yes
read only = no
public = yes
create mask = 0755
comment = put your short description of the server
path = give your directory path to share
browsable = allow Windows Explorer
guest = allows clients without password
read only = yes or no
create mask = new files will have this permission #eg 0755
Give correct permission to your shared folder
sudo mkdir -p /srv/samba/share
sudo chown nobody.nogroup /srv/samba/share/
sudo chmod 777 /srv/samba/share/
PUBLIC READ & WRITE
[Public]
comment = Read Write
path =/srv/samba/share
ready only = no
public = yes
browsable = yeswriteable = yes
create mask =666
directory mask =777
Restart samba services to allow new configuration to take effect
sudo service smbd restart
sudo service nmbd restart
How to setup secure share:
Create a new folder to host secure files
sudo mkdir -p /srv/samba/secured
Create a new group that will access the secured folder.
sudo addgroup securedgroup
Change the ownership and permission on the secured folder so that only members of the securedgroup can access it.
cd /srv/samba/secured
sudo chown -R kim:securedgroup secured
sudo chmod -R 0770 secured/
Configure secure setting on smb.conf
sudo nano /etc/samba/smb.conf
[secured]
path = /srv/samba/secured
valid users = @securedgroup
guest ok = no
writable = yes
browsable = yes
Add new user kim to the secured group (securedgroup)
sudo usermod -a -G securedgroup kim
Create Samba password for user kim and add to Samba user database.
sudo smbpasswd -a kim
Restart Samba for new user kim to access the secured folder
sudo service smbd restart