Sabtu, 16 Januari 2016

Analyzing web traffic with awstats

http://www.freebsdmadeeasy.com/tutorials/web-server/analyze-apache-web-server-logs-with-awstats.php

Once your web server is up and running it is important to analyze your logs to see what searches are bringing users to the sites, how long they are staying, and what pages they are coming in and going out on. One of the most popular open source tools for this task is awstats.

Installing awstats from the ports

# cd /usr/ports/www/awstats
# make install
Awstats installs to /usr/local/www/awstats and needs to following lines added to your apache httpd.conf
#
# Directives to allow use of AWStats as a CGI
#
Alias /awstatsclasses "/usr/local/www/awstats/classes/"
Alias /awstatscss "/usr/local/www/awstats/css/"
Alias /awstatsicons "/usr/local/www/awstats/icons/"
ScriptAlias /awstats/ "/usr/local/www/awstats/cgi-bin/"

#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/local/www/awstats/">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
After this you will need to restart apache for the settings to take effect.
# apachectl graceful

Configuring awstats

A config file must be created for every website. These are placed in /usr/local/www/awstats/cgi-bin The awstats.model.conf is the example file so first copy it over so that you have a new one to work with.
# cp awstats.model.conf awstats.yoursite.conf
Once you have a file for your site open it and begin editting it. There are many options which are explained in the file, but the only necessary ones to change are the hostname, and any aliases used for the site. You also need to change the log type if you are not using the apache combined format.

Updating the stats

Viewing the stats is a seperate process from updating the stats. To have awstats parse your log files and update the stats daily you need to create a cron job for awstats.
30 4 * * * /usr/local/www/awstats/cgi-bin/awstats.pl
  -update -config=yoursite 
The above will update the stats using the awstats.yoursite.conf file every morning at 4:30am. Notice that for the config file awstats.yoursite.conf the awstats and conf are left off.

Updating multiple sites

Once you get a large number of sites added to awstats keeping tracking of all the crons to update them can be a problem, especially if you are trying to keep them all from running at the same time by spacing out the times. To simplify things you can use this awstats updater script to update the stats for every config file in the awstats/cgi-bin.

Viewing the stats

Now that the stats have been updated you can view them online by pointing your browser to www.yoursite.com/awstats/awstats.pl?config=yoursite

Howto use multiple SSH keys for password less login

http://www.cyberciti.biz/tips/linux-multiple-ssh-key-based-authentication.html 


Step # 1: Generate first ssh key

Type the following command to generate your first public and private key on a local workstation. Next provide the required input or accept the defaults. Please do not change the filename and directory location.
workstation#1 $ ssh-keygen -t rsa
Finally, copy your public key to your remote server using scp
workstation#1 $ scp ~/.ssh/id_rsa.pub user@remote.server.com:.ssh/authorized_keys

Step # 2: Generate next/multiple ssh key

a) Login to 2nd workstation
b) Download original the authorized_keys file from remote server using scp:
workstation#2 $ scp user@remote.server.com:.ssh/authorized_keys ~/.ssh
c) Now create the new pub/private key:
workstation#2 $ ssh-keygen -t rsa
d) Now you have new public key. APPEND this key to the downloaded authorized_keys file using cat command:
workstation#2 $ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
e) Finally upload authorized_keys to remote server again:
workstation#2 $ scp ~/.ssh/authorized_keys user@remote.server.com:.ssh/
You can repeat step #2 for each user or workstations for remote server.

Step #3: Test your setup

Now try to login from Workstation #1, #2 and so on to remote server. You should not be asked for a password:
workstation#1 $ ssh user@remote.server.com
workstation#2 $ ssh user@remote.server.com