Showing posts with label script. Show all posts
Showing posts with label script. Show all posts

Friday, December 05, 2014

How To Install DenyHosts on Ubuntu

What is DenyHosts?

This is a python-script for the protection of  ssh server, like fail2ban, but consumes 

far less memory. The script parses the log file and finds failed login attempts and 

prohibits login from these IP addresses.

Installation steps.


Installation process is simple and contains some steps:

1. Retrieve new lists of packages

sudo apt-get update

2. Installation DenyHosts:

sudo apt-get install denyhosts

If the process is successfully completed, you will see the information of the screen:




After installation you can add your IP address in whitelist:

sudo nano /etc/hosts.allow

and insert following string:

sshd: 12.34.45.678

Where “12.34.45.678” – your IP address

And restart denyhost:

sudo service denyhosts restart

Configuration denyhosts.


After the installation process, the DenyHosts is ready to work, but some 

configuration options are noteworthy. All configuration values are in the file 

/etc/denyhosts.conf

1. PURGE_DENY: removed HOSTS_DENY entries that are older than this 

time.

Default value is empty and all listed ip-addresses remain in the file 

/etc/hosts.deny forever.

2. BLOCK_SERVICE: the service name that should be blocked in 

HOSTS_DENY

Default value = sshd, By default, the service protects only ssh server, but it 

can be customized to other services.

3. ADMIN_EMAIL: if you would like to receive report from denyhosts.

Default value = root@localhost, but you can change this value to your email.

After changing the settings, you should restart the DenyHosts again:

sudo service denyhosts restart

The result of  DenyHosts you can see in the file:  /etc/hosts.deny





Sunday, December 03, 2006

double loop script example

#!/bin/bash

i=0
for ID1 in $(awk -F":" '{print $2}' /tmp/components) ; do
id1[$i]=$ID1
i=$(($i+1))
done
j=0 ; while [ $j -lt $i ] ; do cmvt_component_os=${id1[$j]}; echo $cmvt_component_os ; j=$(($j+1)) ; done

Thursday, January 19, 2006

just a nice transfer script

Following
#!/bin/bash
#
#
#

og_log_id=$1.log

function og_xml_upp_ftp {
ftp -n << EOF
open server
user (your user)" "
lcd (your directory)
bin
hash
put $og_log_id.gz
bye
EOF
rm (your directory)$og_log_id.gz
}

function og_logs_compess {
cp (your directory)$og_log_id /xtr/log_xfer
gzip /xtr/log_xfer/$og_log_id
}


case $1 in
'xml')
og_logs_compess
og_xml_upp_ftp
;;
'console')
og_logs_compess
og_xml_upp_ftp
;;
'both')
og_log_id=xml.log
og_logs_compess
og_xml_upp_ftp
og_log_id=console.log
og_logs_compess
og_xml_upp_ftp
;;

*)
echo "Usage: $0 (your text)"
exit 1
;;
esac

Sunday, October 16, 2005

nagios plugin script for checking status of mirrored drives via nrpe.

Following script need to be defined in both nagios comamnds and nrpe agent on the client side

#!/bin/bash
# Copyright (c) 2005 Opengaming Israel, Naor Weissmann
# operations: check if all metastat unitx are operational.
#
RETSTR="initial"
RETVAL=0
youtput=`metastat |grep -i stat |grep 'State:' |grep -v 'Okay' |wc -l`

if [ $youtput -eq 0 ]; then
RETVAL=0
RETSTR="OK - All metadevices are stable"
else
RETVAL=2
RETSTR="ERROR - Metadevices need Maintainence"
fi

echo $RETSTR
exit $RETVAL

2026. What I Actually Do Now

It’s been over 20 years of on-and-off dumping into this blog. 27 and going years in tech, more than 10 years around AI, going back to Heili ...