Samba User Creation on Samba Server
We can create a user for Samba Server who can own files and directories.
First we create a Linux user who can’t login to any shell.
# useradd -s /bin/false sambauser
# passwd password
Changing password for user sambauser.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
Now we create a samba share directory for the user with owner permissions.
# mkdir /home/samba/sambauserdir
# chown -R sambauser:sambauser /home/samba/sambauserdir
The user created for samba should be recognized by Samba server. For adding Linux user to Samba we use smbpasswd and create a samba password.
# smbpasswd -a sambauser
New SMB password:
Retype new SMB password:
Added user sambauser.
# smbpasswd -a sambauser
New SMB password:
Retype new SMB password:
Added user sambauser.
The Samba password is stored in /etc/samba/smbpasswd
We can use the force user and force group options to make sambauser as the owner of the file. Now all new files created in the Sambauserdir share are owned by the same sambauser.
Global section should look like
[global]
workgroup = WORKGROUP
server string = Samba Server
netbios name = LinuxSamba
security = share
We will use force user in share section
[share]
path = /home/samba/sambauserdir
comment = files to write
force user = sambauser
force group = sambauser
read only = no
guest ok = yes
Force user and Force Group
We can use the force user and force group options to make sambauser as the owner of the file. Now all new files created in the Sambauserdir share are owned by the same sambauser.
Global section should look like
[global]
workgroup = WORKGROUP
server string = Samba Server
netbios name = LinuxSamba
security = share
We will use force user in share section
[share]
path = /home/samba/sambauserdir
comment = files to write
force user = sambauser
force group = sambauser
read only = no
guest ok = yes
When anyone connect to the share and write a file, then this sambauser will own the newly created file.
No comments:
Post a Comment