Difference between revisions of "Old:4.0-Mona: Security & passwords"

From The Uniform Server Wiki
Jump to navigation Jump to search
(Punctuation and grammatical changes; some clarification.)
m (BobS moved page 4.0-Mona: Security & passwords to Old:4.0-Mona: Security & passwords without leaving a redirect)
 
(No difference)

Latest revision as of 12:45, 21 June 2013

 

The Uniform Server 4-Mona

Security and passwords

New users may find Uniform Server’s security features a little bewildering. This page attempts to explain their use and when passwords are required.

Default installation

After extracting Uniform Server 4-Mona it’s ready to run and very secure. Apache and MySQL servers are locked down allowing only local access. No external access is allowed from either Intranet or Internet, so even though you are connected to these you can safely develop a web site.

Uniform Server 4-Mona achieves this lock down through the use of .htaccess files placed in each folder that is protected. The file also protects any sub-folders in that folder.

Each of these folders contains an .htaccess file:

\UniServer\udrive\home\admin\www – Control panel for the server
\UniServer\udrive\www            – Server web-root folder (your web site ) 
\UniServer\udrive\ssl            – Server secure web-root (your secure web site)

Open either of the .htaccess files and you will find these three lines

Order Deny,Allow
Deny from all
Allow from 127.0.0.1 

The first line informs Apache to look for the next two lines and execute them in that order (Deny and then Allow)

The second line denies access to every one (all)

The third line is very specific and allows access from IP address 127.0.0.1. This is the IP address of the local machine. Hence Apache is locked down allowing access only from this IP. (IP address 127.0.0.1 is also referred to as the local loopback address).


Allowing external access

To put your servers on-line you need to allow external access. This can be achieved by commenting (adding a hash “#” to the beginning of each line) the three lines as shown below:

 
#Order Deny,Allow
#Deny from all
#Allow from 127.0.0.1

Alternatively you could delete the three lines.

With the lines commented out, everyone connected to the Internet or Intranet has access to the folders that the .htaccess file was protecting.

Your web site or sites are placed in the folders:

 
\UniServer\udrive\www  – Server web-root folder (your web site ) 
\UniServer\udrive\ssl  – Server secure web-root (your secure web site)

These are now available and pages will be served by Apache from these folders.

However by modifying the .htaccess file in folder \UniServer\udrive\home\admin\www you will have allowed everyone access to your server’s control panel (kiss your servers goodbye. OK, I was after a dramatic impact.) There are additional security features that prevent this, however I recommend you do not place Apanel on-line. If you must do it, make sure you enable name/password protection.


Name/Password protection

You may wish to prevent other Internet users accessing your server (a personal web server) this can be achieved by forcing a user to enter a name and password. Uniform Server has this facility pre-configured, Apanel allows you to set a name and password for three specific areas of the server. Under Configurations (left menu) you will find these three links:

  • Admin Panel Configuration
  • Private Server Configuration
  • Private Secure Server Configuration

Even after setting a name and password, they do not become effective unless enabled in the appropriate .htaccess file. Let's look at these in more detail.

A) Admin Panel Configuration

If you have placed Apanel on-line it must be protected with a name and password as follows:

Edit file: \UniServer\udrive\home\admin\www\.htaccess

At the bottom of this file, un-comment (remove the hash”#”) the last four lines as shown:

AuthName "Uniform Server - Admin Panel 2.0"
AuthType Basic
AuthUserFile /htpasswd/home/admin/www/.htpasswd
Require valid-user

First line is the text displayed in the browser pop-up

Second line informs Apache the type of authentication (Basic)

Third line is the location of the file containing the name/password pair

The fourth line tells Apache to instruct a browser that a name and password are required.

To change name and password using Apanel, click on the link “Admin Panel Configuration.” A new page opens showing current name/password. Enter the new name and password click change.

Alternatively, edit file /htpasswd/home/admin/www/.htpasswd and enter a name and password in the following format:

aname:apassword

Note: Do not add any additional characters or carriage return (enter key) after the password.

Test: Enter the following into your browser

http://localhost/apanel/

or

http://your_domain/apanel/

In both cases you will be challenged for a name and password.

Note: Default name and password are root:root

B) Private Server Configuration

You can protect your web site with a name and password as follows:

Edit file: \UniServer\udrive\www\.htaccess

At the bottom of this file, un-comment (remove the hash”#”) the last four lines as shown:

AuthName "Uniform Server - Server Access"
AuthType Basic
AuthUserFile /htpasswd/www/.htpasswd
Require valid-user

First line is the text displayed in the browser pop-up

Second line informs Apache the type of authentication (Basic)

Third line is the location of the file containing the name/password pair

The fourth line tells Apache to instruct a browser that a name and password are required.

To change name and password using Apanel, click on the link “Private Server Configuration.” A new page opens showing current name/password. Enter new name/password click change.

Alternatively, edit file /htpasswd/www/.htpasswd and enter a name and password in the following format: aname:apassword

Note: Do not add any additional characters or carriage return (enter key) after the password.

Test: Enter the following into your browser

http://localhost

or

http://your_domain/

In both cases you will be challenged for a name and password.

Note: Default name and password are root:root

C) Private Secure Server Configuration

You can protect you secure web site with a name and password as follows:

Edit file: \UniServer\udrive\ssl\.htaccess

At the bottom of this file un-comment (remove the hash”#”) the last four lines as shown

AuthName "Uniform Server - Server Access" 
AuthType Basic
AuthUserFile /htpasswd/ssl/.htpasswd
Require valid-user

First line is the text displayed in the browser pop-up

Second line informs Apache the type of authentication (Basic)

Third line is the location of the file containing the name/password pair

The fourth line tells Apache to instruct a browser that a name and password are required.

To change name and password using Apanel, click on the link “Private Secure Server Configuration.” A new page opens showing current name/password. Enter new name/password click change.

Alternatively, edit file /htpasswd/ssl/.htpasswd and enter a name and password in the following format: aname:apassword

Note: Do not add any additional characters or carriage return (enter key) after the password.

Test: Enter the following into your browser

https://localhost/

or

https://your_domain/

In both cases you will be challenged for a name and password.

Note 1: Default name and password are root:root

Note 2: Make sure you have generated a new server certificate and key as detailed on this page.


MySQL Password

The MySQL server has been locked down for local access and protected by a password. If you have not put Apache on-line there is no need to change the password (default root). However it is good practice to change this at the earliest opportunity.

With Apache on-line there is a risk either through malicious intent or a rouge script to gain access to the MySQL server’s root user hence change the password. Note access remains local because user root has been restricted to local access.

To change the MySQL password use Apanel, click on the link “MySQL Server Configuration ” a new page opens showing current password (default root). Enter new password click change; there is no need to re-start the server.


Note 1: After changing either the MySQL port or password you may find server access is no longer possible using phpMyAdmin. A common cause is your browser cache close down servers and browser then restart.

Note 2: If for any reason the password becomes corrupted don’t panic use the password recovery link, found under Apanel's Plugin Manager section (left menu). Alternatively check out this page, how to manually create a new password.

Note 3: If you need to quickly back-up your databases no need to use phpMyAdmin or any other tool just back-up folder UniServer\udrive\usr\local\mysql\data this contains all databases.


Summary

In terms of security, if you are using the server for development there is nothing to do.

If you are putting the servers on-line, they need to be enabled first by editing each of the .htaccess files in each web-root folder (www and/or ssl). Comment the lines as shown:

#Order Deny,Allow
#Deny from all
#Allow from 127.0.0.1

If you want a personal server with name/password access, uncomment the last four lines in the above .htaccess files. Remember to change the name/password pairs using Apanel or manually edit the appropriate file.

Note 1: All names and passwords are set to a value of root

Note 2: Additional information can be found on the Security features page, which includes Apanel's Security Center page.