Showing posts with label Linux.... Show all posts
Showing posts with label Linux.... Show all posts

Zorin OS - An alternative OS for windows users

Hi Guys, Recently i was searching for an open source OS for my desktop and found this Zorin OS whose interface was very similar to windows 7. It is one cool linux OS and very similar to Ubuntu.

Zorin OS is a multi-functional operating system designed specifically for Windows users who want to have easy and smooth access to Linux. It is based on Ubuntu which is the most popular Linux operating system in the world.

Zorin OS features unique Look Changer program that have created exclusively for Zorin OS. It allows users to change the user interface at the touch of a button. Other unique programs include Splash Screen Manager, Internet Browser Manager and Background Plus.

Zorin OS gives users more flexibility. It allows you to use Zorin OS alongside your current operating system and run Microsoft Windows programs in Zorin OS with the help of WINE and PlayOnLinux.

Visit www.zorin-os.com for more details..

Samba file server with AD authentication

Prerequities
Fedora 8 with base

vim /etc/selinux/config
"SELINUX=disabled"

vim /etc/hosts
"192.168.123.228 test-ad.contoso.com test-ad"

yum install ntp
ntpdate

yum install samba
yum install samba-common
yum install samba-client
yum install samba-swat

chkconfig smb on
service smb start
service nmb start
chkconfig nmb on

cp /etc/samba/smb.conf /etc/samba/smb.conf.original

vi /etc/xinetd.d/swat
"only_from = 127.0.0.1 192.168.123.0/24"
"disable = no"

service xinetd start
chkconfig xinetd on

connecting the samba server to the AD

setup -> Authentication configuration
(only check following options)
-Use Winbind
-use MD5 passwords
-Use Shadow Passwords
-Local authorization is sufficient

-> next ->

-Security Model = ads
-Domain = CONTOSO.COM
-Domain Controllers = test-ad.contoso.com
-ADS Realm = CONTOSO.COM
-Template Shell = /sbin/nologin

-> next -> yes ->

Domain Administrator = Administrator
Password =

-> Ok -> Ok -> Quit

("wbinfo -u" command returns domain user list if the ad join is successful)


####################################################

vim /etc/nsswitch.conf

passwd: compat winbind
shadow: compat
group: compat winbind

###################################################

init 6 (restart the server)

####################################################

iptables rules for samba share access

iptables -A INPUT -m multiport -p TCP -s 192.168.123.0/24 --destination-ports

631,139,445 -j ACCEPT
iptables -A INPUT -m multiport -p UDP -s 192.168.123.0/24 --destination-ports

631,137,138 -j ACCEPT

iptables rules for SWAT access on port 901

iptables -A INPUT -p TCP -s 192.168.123.0/24 --destination-port 901 -j ACCEPT

####################################################

use http://samba-server-IP:901 to configure shares

[global]
workgroup = CONTOSO
realm = CONTOSO.COM
server string = Samba Server Version %v
security = ADS
password server = test-ad.contoso.com
passdb backend = tdbsam
log file = /var/log/samba/log.%m
max log size = 50
socket options = TCP_NODELAY SO_RCVBUF=16384 SO_SNDBUF=16384
preferred master = No
dns proxy = No
ldap ssl = no
idmap uid = 16777216-33554431
idmap gid = 16777216-33554431
template shell = /sbin/nologin
winbind enum users = Yes
winbind enum groups = Yes
cups options = raw
[administrator]
path = /home/administrator
valid users = contoso\administrator
admin users = contoso\administrator
read only = No

####################################################
create samba directories on samba server

mkdir /home/administrator
chmod 777 /home/administrator
chmod a+s /home/administrator

####################################################
Please note that in my examples I've made following assumptions
192.168.123.0/24 is my LAN ip block
contoso.com is my AD domain
192.168.123.228 is my AD's IP
test-ad.contoso.com is my AD machine name

scp - Linux command line tool to copy files over ssh

scp stands for secure cp (copy), which means that you can copy files across an ssh connection that will be encrypted, and therefore secured. The server should be capable of handling SSH and the port 22 should be open

You can this way copy files from or to a remote server, you can even copy files from one remote server to another remote server, without passing through your PC.

Usage

scp [[user@]from-host:]source-file [[user@]to-host:][destination-file]

Description of options

from-host Is the name or IP of the host where the source file is, this can be omitted if the from-host is the host where you are actually issuing the command

user Is the user which have the right to access the file and directory that is supposed to be copied in the cas of the from-host and the user who has the rights to write in the to-host

source-file Is the file or files that are going to be copied to the destination host, it can be a directory but in that case you need to specify the -r option to copy the contents of the directory

destination-file Is the name that the copied file is going to take in the to-host, if none is given all copied files are going to maintain its names

Options

-p Preserves the modification and access times, as well as the permissions of the source-file in the destination-file
-q Do not display the progress bar
-r Recursive, so it copies the contents of the source-file (directory in this case) recursively
-v Displays debugging messages

Examples

scp *.txt user@remote.server.com :/home/user/

This will copy all files with .txt extension to the directory /home/user in the remote.server.com host

scp -r eranga@10.1.2.2:/home/eranga/ eranga@10.1.2.3:/home/eranga/

This is going to recursively copy all files from eranga's Home directory on 10.1.2.2 host to his Home directory in 10.1.2.3 host.

A simple Perl script to convert Nagios/Squid logs time to a human readable format

########################################################

Installation steps

#######################

vim nagios-time-converter.pl

Paste the following codes and save the file

#!/usr/bin/perl

# ------------------------------------------------------------
# nagios-time-converter.pl
# ------------
# by:- Eranga Perera
# a perl script to convert Nagios "epoch time" (epoch seconds)
# into a human-readable format.
# ------------------------------------------------------------

$num_args = $#ARGV + 1;
die "Usage: this-program epochtime (something like '1279236316')" if
($num_args != 1);

$epoch_time = $ARGV[0];

($sec,$min,$hour,$day,$month,$year) = localtime($epoch_time);

# correct the date and month
$year = 1900 + $year;
$month++;

printf "%02d/%02d/%02d %02d:%02d:%02d\n", $year, $month, $day, $hour, $min, $sec;

chmod 755 nagios-time-converter.pl

Usage
#######################

./nagios-time-converter.pl 1279236316

########################################################

Groundwork, Nagios and SNMP Traps Integration....!!

Pre Requisites
Minimal installation of CentOS with base package

Disabling selinux
vi /etc/selinux/config
SELINUX=disabled

Yum –y install gcc
cd /usr/src/
wget http://search.cpan.org/CPAN/authors/id/N/NW/NWCLARK/perl-5.8.9.tar.bz2
tar xvf perl-5.8.9.tar.bz2
cd perl-5.8.9
./configure.gnu --prefix=/usr
make
make test
make install

Installing perl modules
perl -MCPAN -e shell
install Text::ParseWords
install Getopt::Long
install Config::IniFiles
install Time::HiRes
install Sys::Hostname
install File::Basename
install Text::Balanced

Installing groundwork
chmod +x groundwork-5.3.0-br46-gw333-linux-32-installer.bin
./groundwork-5.3.0-brXX-gwYYY-linux-32-installer.bin --mode text

Installing net-snmp
yum -y install net-snmp
download net-snmp package to /usr/src (http://www.net-snmp.org)
tar xvzf net-snmp-5.4.2.1.tar.gz
cd net-snmp-5.4.2.1
./configure --with-perl-modules
make
make test
make install

Installing snmptt
tar xvzf snmptt_1.2.tgz
cd /usr/src/snmptt_1.2
cp snmptt /usr/sbin/
cp snmptthandler /usr/sbin/
cd /usr/sbin/
chmod +x snmptt
chmod +x snmptthandler
cd /usr/src/snmptt_1.2
cp snmptt.ini /etc/snmp/
cd /etc/snmp/
create a new file;
vi snmptrapd.conf
and add the following line;
traphandle default /usr/sbin/snmptt

vi /etc/init.d/snmptrapd
Change the OPTIONS="-Lsd -p /var/run/snmptrapd.pid" as below
OPTIONS="-On -Lsd -p /var/run/snmptrapd.pid"

/etc/init.d/snmptrapd restart
cp /usr/src/snmptt_1.2/snmptt-init.d /etc/init.d/snmptt
cd /etc/init.d/
chmod 755 snmptt
chkconfig --add snmptt
chkconfig --level 2345 snmptt on
/etc/init.d/snmptt start

cp /usr/src/snmptt_1.2/snmpttconvert /usr/bin
cp /usr/src/snmptt_1.2/snmpttconvertmib /usr/bin
cd /usr/bin/
chmod 755 snmpttconvert

chmod 755 snmpttconvertmib

snmptt.ini configurations with following values (/etc/snmp/snmptt.ini)
dns_enable = 1
strip_domain = 1
net_snmp_perl_enable = 1
pre_exec_enable = 0
unknown_trap_log_enable = 1


/etc/init.d/snmptt start

Opening 80 port from the firewall
vi /etc/sysconfig/iptables
add the following line
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
/etc/init.d/iptables restart

Access groundwork through a web browser
User name: admin
P/w: admin

Enable notifications
Go to Control --> Nagios main Configurations --> Enable notifications: check the box --> save --> commit

Adding a host
Go to Configuration --> Host Wizard and follow steps Go to Control --> commit --> commit

Submit-check-results
Download submit_check_result from nagios standard distribution
Copy it to /usr/local/groundwork/nagios/eventhandlers/

chmod +x submit_check_result
vi submit_check_result
and change the nagios.cmd file path
/usr/local/groundwork/nagios/var/spool/nagios.cmd

Compiling a MIB
snmpttconvertmib --in= --out=/etc/snmp/snmptt.conf1 --net_snmp_perl

Edit the compiled file and add the following to each and every trap
EXEC /usr/local/groundwork/nagios/eventhandlers/submit_check_result $R TRAP 1 "$*"

Add compiled file paths to the /etc/snmp/snmptt.ini script [...]
[TrapFiles]
snmptt_conf_files = << END
/etc/snmp/snmptt.conf1
/etc/snmp/snmptt.conf2
END

Creating TRAP service
Create a new service with following details

Name : TRAP
use :generic-service
is_volatile :1
check_command :check-host-alive
max_check_attempts :1
normal_check_interval :1
retry_check_interval :1
passive_checks_enabled :1 Active_checks_enabled :0
check_period :24/7
notification_interval :31536000
contact_groups :somegroup

To enable audio alerts edit the following file.
/usr/local/groundwork/apache2/confg/httpd.conf
Add following lines.

ScriptAlias /nagios/cgi-bin "/usr/local/groundwork/nagios/sbin"
< Directory "/usr/local/groundwork/nagios/sbin">
# Uncomment for Guava Single Sign On
AuthType Basic
require valid-user
# The following line should be change to specify the default page for invalid access attempts to this directory
TKTAuthLoginURL http://localhost:80/monitor/index.php
TKTAuthCookieName nagios_auth_tkt
TKTAuthTimeout 0
# Uncomment to disable Guava Single Sign On
# AllowOverride AuthConfig
# Options ExecCGI
# Order allow,deny
# Allow from all
PassEnv LD_LIBRARY_PATH
PassEnv NAGIOS_CGI_CONFIG
< /directory>

Alias /nagios/media "/usr/local/groundwork/nagios/share/media"
< Directory "/usr/local/groundwork/nagios/share/media">
# Uncomment for Guava Single Sign On
AuthType Basic
require valid-user
# The following line should be change to specify the default page for invalid access attempts to this directory
TKTAuthLoginURL http://localhost:80/monitor/index.php
TKTAuthCookieName nagios_auth_tkt
TKTAuthTimeout 0
< /directory>

Hi Friends,,,