How to password protect Samba shares? (solved)

Moderator: Forum moderators

Post Reply
User avatar
wizard
Posts: 1973
Joined: Sun Aug 09, 2020 7:50 pm
Has thanked: 2634 times
Been thanked: 684 times

How to password protect Samba shares? (solved)

Post by wizard »

I have a computer running Stretch 7.5rc5 and have shared two directories using the Samba Simple Management tool. Both can be accessed using the default user name and password. Is it possible to have different passwords for each shared directory?

wizard

Last edited by wizard on Sun Feb 14, 2021 10:00 pm, edited 1 time in total.

Big pile of OLD computers

User avatar
rcrsn51
Posts: 1383
Joined: Sun Aug 23, 2020 4:26 pm
Been thanked: 357 times

Re: How to password protect Samba shares?

Post by rcrsn51 »

You can't (to my knowledge) assign a password to a specific share. However, you can have multiple users that are granted different access to different shares.

But I have no experience with Samba Simple Management, so I can't comment any further.

User avatar
wizard
Posts: 1973
Joined: Sun Aug 09, 2020 7:50 pm
Has thanked: 2634 times
Been thanked: 684 times

Re: How to password protect Samba shares?

Post by wizard »

@rcrsn51

Hi rcrsn51,

Adding the new users worked, thanks for confirming. I had been testing that, but made the mistake of creating the shared directories in /root (instead of in just /) and of course that didn't work.

Simple Samba Manager just writes a quick and simple smb.conf, here's my test example:

Code: Select all

#this is a very simple smb.conf to get you started
#coutesy rcrsn51 and gcmartin
[global]
	workgroup = Workgroup
	netbios name = puppypc30465
	server string = Puppy Samba Server
	security = user
	map to guest = Bad Password
	printing = cups
	printcap name = cups
	load printers = yes

[joe]
	path = /joe
	writable = yes
		
[bob]
	path = /bob
	writable = yes

[printers]
	comment = All Printers
	path = /var/spool/samba
	browseable = no
	guest ok = yes
	writable = no
	printable = yes

This is my solution for password protecting shares with different passwords:

-Create directories (can be any name) in home (/), or any location outside of /root. If you create the directory on another partition or drive, it must be mounted when using the share. My example directory = /joe

Add puppy users for each of the shares you want to protect: example is for new user = joe
-open a terminal
-type: adduser joe
-enter a password for joe when prompted (write it down)

Add samba users for each new user: example is for new user = joe
-open a terminal
-type: smbpasswd -a joe
-enter a samba password for joe when prompted (use same password entered above)

Create samba shares: example is for share=joe
-open Samba Simple Management
-enter share name (can be any name) and path location to the directory created above in the boxes

ssm.png
ssm.png (41.49 KiB) Viewed 2288 times

-click: Test, to make sure samba can find the shares (note: test overwrites the smb.conf file and will delete any manual edits you make)
-click: Apply

Edit smb.conf to protect the share: example is for share=joe
-open: /etc/samba/smb.conf
- in this section, add the valid users line:

Code: Select all

[joe]
	path = /joe
	writable = yes
	valid users = joe

-save the file

Restart samba:
-open Samba Simple Management
-click: SAMBA ON
-click: SAMBA OFF

Test from another computer on the network using Yassm Samba share mounter. Only user joe & joe's password should be able to access the share.

If there's a simpler method let me know.

thanks

wizard

-

Big pile of OLD computers

Post Reply

Return to “Network/Server”