Friday, January 11, 2013

htpasswd to protect a web pages

Lets say you have a have a smokeping services and you wish to protect it with a password. then you can use htpasswd to protect it.

First you need to cd to that folder
# cd  /opt/smokeping

then create a new htpasswd
and add user 'admin'
# htpasswd  -c /opt/smokeping/.htpasswd admin

If you have an existing htpasswd file, then you can just update it using
# htpasswd  /opt/smokeping/.htpasswd admin

after done, you need to enable this in the apache config
you need to add:


<Directory "/var/www/html/smokeping">

     AuthUserFile /opt/smokeping/.htpasswd
     AuthType Basic
     AuthName "Smokeping Admin Pages"
     Require valid-user

</Directory>


Then reload the Apache services


Tuesday, January 8, 2013

SSL cert

Generate the private key
# openssl genrsa -out myserver.key 2048

then generate the Certificate signing request (CSR) from the private key
# openssl req -new -key myserver.key -out myserver.csr

This key will be given to SSL authority to sign the cert and will return back a .crt file
After you get it, put it into apache server and append this into the httpd.conf


    SSLEngine On
    SSLCertificateKeyFile myserver.key
    SSLCertificateFile myserver.crt
    SSLCACertificateFile RapidSSL_CA_bundle.pem

Monday, October 8, 2012

Monitor System with AIDE and SAR

AIDE, Advanced intrusion detection environment is a tool to check the integrity of files on the system


Steps to deploy AIDE
1. install the aide package
2. customize  /etc/aide.conf  to your preference
3. run  /usr/sbin/aide --init  to build the initial database
4. Store  /etc/aide.conf, /usr/sbin/aide, /var/lib/aide/aide.db.new.gz in a secure location
5. Copy /var/lib/aide/aide.db.new.gz  to  /var/lib/aide/aide.db.gz
6. you can run the checking by # aide --check

Result will be display or save to /var/log/aide/aide.log by default


System Activity report

Install the sysstat package
run # sar -A to display all information collected
run # sar -u 2 5 to display five sample of system CPU usage with interval 2 second

Static route

The routing table for the system is display with the ip route show command.

Routing must be enabled with a tunable kernel parameter, named net.ipv4.ip_forward

- 0 = discard foreign packet
- 1 = forward foreign packets to the network interface determined by the routing table

Edit /etc/sysctl.conf  for permanent change and run sysctl -p to reload it



To add a route dynamically

# ip route add  IP/netmask  via  router_IP

To persistent add a route, edit  /etc/sysconfig/network-scripts/route-iface

ADDRESS0=network
NETMASK0=netmask
GATEWAY0=router_ip

Tuning kernel network parameter

Install kernel-doc RPM for the documentation

# sysctl -a
will show all the list

the kernel parameter are located at
/proc/sys/net/ipv4/

Tuesday, October 2, 2012

network monitoring

Detect Local Services
# netstat -tulnp

Detect Remote Services
# nmap -A -sT  <server>

Capturing and analyzing network traffic
# tcpdump -D
to show all available capture interface

Example to capture port 22 from interface eth0
# tcpdump  -nn  -l  -s  2000  -w  packets  -i  eth0  'port 22'

Analyzing network packet with wireshark
install the wireshark-gnome
copy out the output of tcpdumb
# wireshark <tcpdumb file>


sample yum repo

create a file
# touch /etc/yum.repo.d/redhat

then edit it with this sample

[redhat]
name = Redhat
baseurl = http://server.example.com/repo
enabled = 1
gpgcheck = 0