How to protect alias with htpasswd file

Just a simple reminder :

1) Create passwd file:
htpasswd2 -c /etc/apache2/htpasswd USER -> insert password

2) verify grant on path

3) create alias

Alias /protected /root/path
<Location /protected >
        AuthType Basic
        AuthName "download for protected "
        AuthUserFile /etc/apache2/htpasswd
        Require valid-user
</Location>

3 simple step to use .htaccess & .htpasswd

1) Create htpasswd

htpasswd -c /srv/www/htpasswd username —-> <insert password>

2) Put file named .htaccess
containing this lines:

#######################################
AuthUserFile  /srv/www/.htpasswd
AuthType Basic
AuthName "backend"
Require valid-user
#######################################

3) allow override in http.con as follow:

<Directory "/srv/www/htdocs">;
...

# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
AllowOverride AuthConfig
# Controls who can get stuff from this server.
Order allow,deny
Allow from all

...
</Directory>

Hotw to tunnel by ssh from local server to remote One.

Taken From : http://www.revsys.com/writings/quicktips/ssh-tunnel.html

ssh -f user@personal-server.com -L 2000:personal-server.com:25 -N

(working example ssh -f root@192.168.40.91 -L 0.0.0.0:8585:192.168.40.91:8585 -N)
The -f tells ssh to go into the background just before it executes the command. This is followed by the username and server you are logging into. The -L 2000:personal-server.com:25 is in the form of -L local-port:host:remote-port. Finally the -N instructs OpenSSH to not execute a command on the remote system.

To kill tunnel use:

 netstat -anp | grep 8585    —–> find process ID
kill -9 process ID

Restrict access to you subversion Server

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
################################################Svn Config
LoadModule dav_svn_module                 /usr/lib/apache2/mod_dav_svn.so
LoadModule authz_svn_module               /usr/lib/apache2/mod_authz_svn.so
 
 
ServerName svn.yourdomain.local
 
 
DAV svn
SVNPath /var/www/svn1
AuthType Basic
AuthName "Your SVN repository name"
AuthUserFile "/etc/subversion/passwd"
 
Order Deny,Allow
Allow from all
Require user dev