Many sites on the World Wide Web provide public access to the information they contain. Anyone can view the public resource pages. However, it so happens that you need to grant limited access to some sections of websites.
Instructions
Step 1
Connect to ssh server. If you have a console client, then type the command in the console ssh @. For example, the command might look like ssh [email protected]. Enter your password when prompted by your account. You can use alternative client programs under windows. For example, one such program is called putty.
Step 2
On the server, go to a root directory that is not accessible from the web. It usually contains a subdirectory called public_html, which contains all the content of the resource, available for viewing over the Internet. Use the cd command. If you do not remember the full path to the folder, then use the ls command to get the contents of the directory and make step-by-step transitions.
Step 3
Create a password file in the current directory. Run the command htpasswd -c. "-" is a valid filename. For authorization, data will be placed in it. "-" is the user ID. They will have access to the resource section. The command looks like this htpasswd -c.pwd User1. After you enter the command, you will be prompted for a password with the entered username. Password confirmation will be requested after entering the password itself.
Step 4
Now you need to check for the existence of the password file. ls - all - execute this command. The password file name must appear in the displayed list of all contents of the current directory.
Step 5
Add users who will be allowed access. htpasswd - run a command like this.
Step 6
Disconnect from the server. Now enter exit and confirm the command by pressing Enter. Htaccess file. Connect to the server using your FTP client program. Go to the directory that corresponds to the section of the site for which you need authorization. This is how there should be a file called.htaccess - download it to your PC.
Step 7
Go to the section of the site to check the operation of the authorization system. The browser will display a dialog with authorization data if everything is working correctly.