Keskne logihaldus Rsyslog ja SEC näitel: Difference between revisions
No edit summary |
|||
Line 73: | Line 73: | ||
<source lang="bash"> | <source lang="bash"> | ||
type=PairWithWindow # Kasutatakse kahte tingimust (mustrit) | type=PairWithWindow # Kasutatakse kahte tingimust (mustrit) | ||
ptype=RegExp | ptype=RegExp # mustri tüüp | ||
pattern=sshd\[\d+\]: Failed .+ for (\S+) from ([\d.]+) port \d+ ssh2 # muster, mida otsitakse | pattern=sshd\[\d+\]: Failed .+ for (\S+) from ([\d.]+) port \d+ ssh2 # muster, mida otsitakse | ||
desc=User $1 has been unable to log in from $2 over SSH during 1 minute # kirjeldus | desc=User $1 has been unable to log in from $2 over SSH during 1 minute # kirjeldus | ||
Line 86: | Line 86: | ||
5) Käivitage reegel järgmise käsuga | 5) Käivitage reegel järgmise käsuga | ||
<source lang="bash"> | <source lang="bash"> | ||
perl /usr/bin/sec -conf=/etc/sec/ | perl /usr/bin/sec -conf=/etc/sec/rule1.conf -input=/var/log/remote/192.168.56.101/syslog.log | ||
</source> | |||
<source lang="bash"> | |||
Feeding event ' Wed Jan 8 14:35:05 2014: User student has been unable to log in from 192.168.56.1 over SSH during 1 minute' to shell command '/bin/echo Wed Jan 8 14:35:05 2014: User student has been unable to log in from 192.168.56.1 over SSH during 1 minute >> /etc/test' | |||
</source> | |||
== SEC reegli teine näide == | |||
Järgnev reegel logib Puppeti kleindi sulgemist | |||
1) Loome reegli faili | |||
<source lang="bash"> | |||
vim /etc/sec/puppetcheck.conf | |||
</source> | |||
2) Defineerime reegli | |||
<source lang="bash"> | |||
type=SingleWithThreshold #üks muster | |||
ptype=RegExp | |||
pattern=puppet-agent\[\d+\]: Puppet client disabled | |||
desc=Puppeti klient forced to close by $1 | |||
action=pipe '%t : %s' /bin/mail 'puppet error' root@localhost # saadetakse mail | |||
window=3600 #intervall | |||
thresh=1 # kordade arv enne saatmist | |||
</source> | |||
Kontrollida saab antud käslusega | |||
<source lang="bash"> | |||
logger -t puppet-agent -i Puppet client disabled | |||
</source> | </source> | ||
= Kasutatud kirjandus = | = Kasutatud kirjandus = | ||
Line 93: | Line 118: | ||
http://www.thegeekstuff.com/2012/01/rsyslog-remote-logging/ <br/> | http://www.thegeekstuff.com/2012/01/rsyslog-remote-logging/ <br/> | ||
http://www.occam.com/sa/CentralizedLogging2012.pdf | http://www.occam.com/sa/CentralizedLogging2012.pdf | ||
http://simple-evcorr.sourceforge.net/SEC-tutorial/article.html |
Revision as of 19:33, 10 January 2014
Ülesande püstitus
Juhendi eesmärgiks on luua keskne logihaldus Rsyslog ja SEC näitel ning esmane logi seire.
Kasutatud tarkvara ja virtuaalmasinad
Tarkvara
Rsyslog 5.8.6
SEC 2.5.3
Virtuaalmasinad
1) Keskne logiserver: Ubuntu Server 64bit versioon 12.04.3 LTS.
IP aadress: 192.168.56.201
2) Klient: Ubuntu Desktop 64bit versioon 13.
IP aadress: 192.168.56.101
Logiserveri seadistamine
Rsyslog [1]
1) Luua uus virtuaalmasin unikaalse IP-aadressiga.
2) Seejärel tuleks luua kaust logide jaoks.
NB! Kõik käsklused peaksid olema SUDO õigustes
mkdir /var/log/remote
3) Pärast seda tuleks anda kaustale grupi automaatse kirjutamise õigus
chmod g+ws /var/log/remote/
4) Samuti tuleks ka kausta omanik ära vahetada, et syslogil oleks täiendavad õigused.
chown syslog:adm /var/log/remote/
5) Seejärel tuleks lisada konfiguratsioonifaili(/etc/rsyslog.conf) järgnevad read:
# provides TCP syslog reception
$ModLoad imtcp
#default port 514 do not work untill rsyslog has been updated.
$InputTCPServerRun 1025
# This one is the template to generate the log filename dynamically, depending on the client's IP address.
$template FILENAME,"/var/log/remote/%fromhost-ip%/syslog.log"
# Log all messages to the dynamically formed file. Now each clients log (192.168.56.*), will be under a separate directory which is formed by the template FILENAME.
*.* ?FILENAME
6) Pärast seda tuleks kliendi masina konfiguratsioonifaili(/etc/rsyslog.conf) lisada.
# provides TCP syslog reception
$ModLoad imtcp
#default port 514 do not work untill rsyslog has been updated.
$InputTCPServerRun 1025
# Provides TCP forwarding.
#default port 514 do not work untill rsyslog has been updated.
*.* @@192.168.56.201:1025
SEC [2]
1) Installige SEC
apt-get update
apt-get install sec
2) Seejärel tuleks luua kaust
mkdir /etc/sec
3) Pärast seda tuleks luua reegli fail
vim /etc/sec/rule1.conf
4) Reegli faili sisuks tuleks lisada
type=PairWithWindow # Kasutatakse kahte tingimust (mustrit)
ptype=RegExp # mustri tüüp
pattern=sshd\[\d+\]: Failed .+ for (\S+) from ([\d.]+) port \d+ ssh2 # muster, mida otsitakse
desc=User $1 has been unable to log in from $2 over SSH during 1 minute # kirjeldus
action=pipe ' %t: %s' /bin/echo %t: %s >> /etc/test
ptype2=RegExp
pattern2=sshd\[\d+\]: Accepted .+ for $1 from $2 port \d+ ssh2
desc2=SSH login successful for %1 from %2 after initial failure
action2=logonly
window=60 #ajaintervall sekundites
Antud reegel logib SSH pordi pihta tehtud ebaõnnestunuid päringuid. 5) Käivitage reegel järgmise käsuga
perl /usr/bin/sec -conf=/etc/sec/rule1.conf -input=/var/log/remote/192.168.56.101/syslog.log
Feeding event ' Wed Jan 8 14:35:05 2014: User student has been unable to log in from 192.168.56.1 over SSH during 1 minute' to shell command '/bin/echo Wed Jan 8 14:35:05 2014: User student has been unable to log in from 192.168.56.1 over SSH during 1 minute >> /etc/test'
SEC reegli teine näide
Järgnev reegel logib Puppeti kleindi sulgemist 1) Loome reegli faili
vim /etc/sec/puppetcheck.conf
2) Defineerime reegli
type=SingleWithThreshold #üks muster
ptype=RegExp
pattern=puppet-agent\[\d+\]: Puppet client disabled
desc=Puppeti klient forced to close by $1
action=pipe '%t : %s' /bin/mail 'puppet error' root@localhost # saadetakse mail
window=3600 #intervall
thresh=1 # kordade arv enne saatmist
Kontrollida saab antud käslusega
logger -t puppet-agent -i Puppet client disabled
Kasutatud kirjandus
http://www.canonical.com/sites/default/files/active/Whitepaper-CentralisedLogging-v1.pdf
http://www.thegeekstuff.com/2012/01/rsyslog-remote-logging/
http://www.occam.com/sa/CentralizedLogging2012.pdf
http://simple-evcorr.sourceforge.net/SEC-tutorial/article.html