1

I have 100 users. So i need to create a samba folder for each user to access to personal folders with individual username and password.

I will create them with the following format (in smb.conf samba version 4.7.6-Ubuntu)

[finance]
comment = finance PC
path = /home/user/finance
writeable = yes
browseable = no
read only = no
create mask = 0774
directory mask = 0777
valid users = finance
admin users = finance2018

[secretary1]
comment = secretary1 PC
path = /home/user/secretary1
writeable = yes
browseable = no
read only = no
create mask = 0774
directory mask = 0777
valid users = secretary1
admin users = secretary11976

The problem is that I have 100 users (for each PC). Then I must create 100 linux users, 100 users for samba (with 100 passwords) and 100 individual folders.

Is there any way to make this task easier?

acgbox
  • 2,367

2 Answers2

2
  1. In theory unlimited. The hardware is your limit.
  2. Samba supports a [homes] setting. See chapter 9 in the manual.
[homes]
    browsable = no
    writable = yes 

The [homes] share is a special section of the Samba configuration file. If a user attempts to connect to an ordinary share that doesn't appear in the smb.conf file (such as specifying it with a UNC in Windows Explorer), Samba will search for a [homes] share. If one exists, the incoming share name is assumed to be a username and is queried as such in the password database ( /etc/passwd or equivalent) file of the Samba server. If it appears, Samba assumes the client is a Unix user trying to connect to his home directory.

That is likely to be the easiest to manage method for lots of users.

We have a users group (GID 100) you can use to group those users and apply settings to that group.

But the more obvious way would be to use active directory if you have that. Setup almost totally on the Windows side and not on the server.


Mind the part in bold.

Rinzwind
  • 309,379
0

A simple bash script: (read man seq)

#!/bin/bash
for i in $( seq 1 100 ) ; do  printf "%s\n" "[user$i]
comment = user$i
path = /home/user/user$i
writeable = yes
browseable = no
read only = no
create mask = 0774
directory mask = 0777
valid users = user$i
admin users = user12018
"
done
waltinator
  • 37,856