GoAdmio Command Line: directory with /go/directory

/go/directory puts a username and password in front of a folder on a website. Visitors must log in before they can see anything in it. It uses Apache's Basic authentication, which relies on two files in the folder: It also records the protected folder in the GoAdmio database, and it can remove the protection again. Every admin action in GoAdmio has a matching /go/ command, so anything you can click you can also script.

Quick start

# Protect a folder with one login
/go/directory example.com /home/example.com/www/private editor S3cure_Pass9

# Remove the protection
/go/directory example.com /home/example.com/www/private delete

Arguments

Position Argument Required Notes
1 <account> Yes The GoAdmio account username, not the domain name (although the two are the same by default). It is only stored in the database.
2 <directory> Yes The full path of the folder, such as /home/example.com/www/private. It must already exist.
3 <user> Yes The login name visitors will type. The word delete removes the protection instead, so it can’t be used as a login name.
4 <password> To protect The login password. Not used with delete.

Avoid spaces, quotes, and shell or SQL special characters ($ & ; | ' ") in the directory, user, and password. They are used without quoting and can break the command.

Examples

# Protect a folder, then check that the server asks for a login (expect 401)
/go/directory example.com /home/example.com/www/private editor S3cure_Pass9
curl -I https://example.com/private/

# Back up an existing .htaccess before protecting the folder
cp -a /home/example.com/www/private/.htaccess /root/htaccess.private.bak
/go/directory example.com /home/example.com/www/private editor S3cure_Pass9

# Add a second login without replacing the first
sudo htpasswd -b /home/example.com/www/private/.htpasswd second_user An0ther_Pass

# Remove the protection
/go/directory example.com /home/example.com/www/private delete

Output

Message Meaning
Adding password for user <user> Printed by htpasswd when the login is created.
Directory <directory> has been protected The folder is now password-protected.
Directory privacy has been deleted The protection was removed.
No output The directory doesn’t exist. Nothing was changed.

The command exits with status 0 in every case, so don’t rely on the exit status. Check the message, or test the site.

See the full reference at /go/directory and the GoAdmio command index.

GoAdmio is free and open source, with no license fees and no account limits. Read the GoAdmio docs, or see why it is a free cPanel alternative at goadmio.com.

By:

Posted in:


Leave a Reply

Your email address will not be published. Required fields are marked *