Jump to content
We're Hiring! Full Stack Developer ×

Change SMB security of a share via SSH


Recommended Posts

I am writing a list of commands to run via SSH to backup my files monthly.


I am wanting to run a command to change the SMB security of a share from Public to Secure before I start,

then another command to do the opposite when completed.

Instead of having to load up the Web UI and doing it that way.

 

Is there a way to do that?

Link to comment

I think I figured it out. I found where the config files for each share is located:

/boot/config/shares/SHARENAME.cfg

All I did was changed the SMB permission on the WEB UI to each of the three and made a copy of

the config each time to a folder to have all three permission types for that share.

Then I run commands to append the config file with .BAK, then copy one of the three that I copied

to where the config files are housed, and name the copied file to what the .BAK one was named.

I also added a line at the beginning to delete any .BAK that was present for some reason to

prevent corruption issues.

 

Pre Backup script:
rm -f '/boot/config/shares/SHARENAME.cfg.BAK'
mv '/boot/config/shares/Cloud-Files.cfg' '/boot/config/shares/Cloud-Files.cfg.BAK'
cp '/mnt/disks/PATH-TO-FILE/SHARENAME.cfg-DESIREDPERMISSION.bak' '/boot/config/shares/SHARENAME.cfg'

 

Once backups are completed, I delete the config file that was copied over, then truncate .BAK

from the original file name to restore it back into place.

 

Post backup script
rm -f '/boot/config/shares/SHARENAME.cfg'
mv '/boot/config/shares/SHARENAME.cfg.BAK' '/boot/config/shares/SHARENAME.cfg'

 

Hope this helps anyone who goes searching for wanting to do anything similar to this.

Keep in mind, if you change any settings for the share, you will want to replace your

copies of the config file or you may cause problems with your share(s).

Link to comment

It makes all the files in the share read-only to any guest user who tries to access it. That way none of the files can be modified while the backed up is being conducted. But if you needed to access a file(s) for whatever reason, you can still do so. You could also do Private instead, to stop guests from accessing the share completely.

 

In my use case, all our devices access shares as guest. So changing a share to Secure makes it read-only.

  • Upvote 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...