How to set up protected directories using scripts

Hi All.

I have looked, but can’t find anything relevant. Was wondering if there was a way to add a protected directory and add a user to that via scripts, or by running a command?

Any help would me much appreciated thanks

You can do that with users and groups configuration. On the Webmin tab under system you have a Users and Groups tab. What you would do is create a new group for the people you want to have access to that given folder.

Then you would create the folder. Then you would change the ownership of that folder to the group you had assigned to have access. Then only that group would be able to go to that folder.

Lastly, you would edit the user and add that group to them so they will have access.

Hi @Gomez_Adams
Thanks for the reply. However, I’m happy doing all this via the gui, and it works as expected. If you revert to my question, I was specifically asking on how to do this on the command line, or via a script.

If you know how to do that, I’ll be over the moon.
I’ve not managed to find anything, but wonder if something like remote api, or something similar would help in this regard. Maybe @Ilia or @Joe might cast some insight on this, if and when they get the time, as I assume they must have a very busy schedule.

@neural hi what’s the script, would you share the code here on forum?

Hi @unborn
I’m actually needing the script!
I have a bash script at the moment, that does a lot of things for me, but one thing I need, is to be able to control protected directories via the command line. I could go and figure this out, from Apache side, however, I’m not sure what Virtualmin is doing with regard to this on the backend, so I’d rather have this handled from within Virtualmin, rather than me messing around with other things that could cause conflicts with Virtualmin.
Hope this clarifies things.

@neural well it’s simple, you can control this functionality manually via virtualmin gui or use bash, basically tell the bash to apply htaccess to folders you need to also tell 8t to create htpass file somewhere with usernames and passwords and you’re ok.

Hi @unborn, we seem to be going around in circles.
I need the virtualmin command, or something else, if available. I will only as a last resort, use methods outside of virtualmin functionality, so as to avoid conficts etc.

I see, sorry for misunderstanding, well I’m sorry I don’t know virtualmin commands. try official documentation? good luck.

Thanks, I have checked the documentation, but can’t find anything…thus was hoping that someone on the forums could offer some insight or solution.

You might try just entering “virtualmin” +enter at the command line of your Virtualmin server.

You might find something useful that way.

G

Thanks @sonoracomm I did go in and check, but couldn’t find what I was looking for. Maybe it’s hidden away at some deeper level. I did drill down into a couple of these, but no luck!

So I found the scripts’ folder for this: /usr/share/webmin/virtualmin-htpasswd however, I don’t really know Perl, so it’s not easy for me to read the code to see what’s happening underneath.

Just adding this in as extra, taken from one of my replies below:
“So I found the scripts’ folder for this: /usr/share/webmin/virtualmin-htpasswd however, I don’t really know Perl, so it’s not easy for me to read the code to see what’s happening underneath.”

Hopefully some Perl guys could share some knowledge?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.