Na zahtevo prijateljev in uporabnikov vam bom predstavil tukaj kako si doma namestit WEBScada – Pametna Hiša vizualizacija za spet za CybroTech Kontrolerje – Robotina.si oz. Robitina.com – CybroTech.com – PCS-NET nadzor IP kamere, Centralno gretje, Klima, Luči, TV sprejemnik – Statelit Astra 1,2,3 in video snemalnik. – popravek za Raspbian 11 Linux / 2022 NI VEČ RAČUNA PI DIREKTNO GENERIRAJTE VAŠ ADMIN RAČUN KARKOLI NPR. webscada (PS Raspbian 11 nima po defaultu nameščen python2 in pip oz. pip2 – namestite python2 in določite python-is-python2, šele pol namestite vse potrebne module in webscada!)

Osebno nisem računalničar in to je moja logika postavitve strežnika rasbian in namestitev web scade! Vsekakor bo kakšen strokovnjak na področju ITS oz. informacijskih sistemov menil, da bostaja boljši način. Zato je najbolje da se obrnete na pomoč na staneh Robotina.si:

Za vse Uredniške račune, Avtorske račune lahko dostopate do mojih člankov in objav preko URL: https://perc.ddns.net – privatni in javni blog wordpress, bbForum in ostale fukncionalnosti strežnikov z nadzornimi ploščami (uporabite za dostop unikodo in vaše uporabniško ime)!

POZOR POMEMBNO OPOZORILO SPODNJI PODTOPEK NAMESTITEVE WEB SCADA CYBROTEC KONTROLERJI VELJA ZA RAZLIČNICO OPERACIJSKEGA SISTEMA UBUNTU 18, RASPBIAN 10 IN DEBIAN 10

V KOLIKOR BOSTE NAMESTILI OPERACIJSKI SISTEM UBUNTU 20, RASPBIAN11 DEBIAN11 PO DEFAULTU PYTHON2 NI NAMEŠČEN IN V REPOSITORIJIH JE VEČINA MODULOV MENJANIH OZ. NE OBSTAJAJO VEČ ZA PYTHON2 JIH JE POTREBNO NAMESTIT IZ SURCE DATOTEKE!!!! APACHE WSCGI, MODULI PYTHON MYSQL itd…

Rezervirajte na vašem usmerjevalniku oz. routerju za vašo napravo PI-3-4 Raspberry – Če imate TPLink router in dinamični internet (javno) v meniju Dynamic DNS nastavite še noip.com. Za ostale lahko namestite v vaš raspberry PI mini server aplikacijo za linux.

Registrirajte račun pri noip.com te pristopne podatke vnesete ob namestitve noip za linux DUC intervalno gledanje vašega IPja in morebitne spremembe, za dinamični internet, statika oz. statični internet ne rabi, ker boste vezali vaš ip naslov na domeno, ki jo generirate pri noip.com + brezplačno velja domena 1 mesec po ene mesecu boste mogli podaljšat, če ne se ukine dokler jo ne obnovite v nadzorni plošči noip.com.

Ko namestite celoten rasbian linux minimal install obvezno postopek kako namestit na PI4 noip.com DUC aplikacijo – da boste dobili namesto IP domeno za vaš mini serverček – registriraje na doemeni noip.com vaš račun brezplačno.

webscada@mojascada :~ $

cd /usr/local/src/
sudo wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz
tar xf noip-duc-linux.tar.gz
sudo rm noip-duc-linux.tar.gz
cd noip-2.1.9-1/
sudo make install

Your username is: noip.com uporabniško ime
Your password is: noip.com pristopno geslo

cd /etc/
sudo nano rc.local

# kopijaj to zraven direktive oz. dodaj spodaj sudo nano noip2
# rc.local
sudo -u webscada /home/linuxter/app/scgi_server/src/run_scgi_server.py
# TAM ODKOMENTIRAJTE KOT STE NAMESTILI NA PI4 WEB SCADO PRIMER
sudo noip2
# SHRANI IN PONOVNI ZAGON PI

sudo shutdown -r now


sudo noip2 -S

💡 ZAČETEK PRIPRAVA SERVERJA

Pomembno, za Raspbian 10 Buster minimal install obvezno prvo namestite Apache, MariaDB server in client, php7.4 in vse potrebne python module in dodatno programsko opremo!

01) Potrebna strojna oprema za spletni strežnik Raspberry Pi
potrebovali boste:

  1. Raspberry Pi seveda. Potrebovali boste tudi napajalno enoto in etui.
  2. Tipkovnica USB, miška USB, monitor s povezavo HDMI in kabel HDMI.
  3. Čitalnik kartic SD.
  4. USB ključek za shranjevanje podatkov, čeprav to ni obvezno, saj lahko za shranjevanje podatkov uporabite kartico SD. Zdaj na novih PI4 namesto SD kartice lahko kupite tudi USB3 plavi priključek od raspberry SSD Disk nrp. 2-TeraBajta – 2048 MB (namesto sd kartice zapečete OS Rasbian na USB Disk)
  5. Ethernetni kabel za povezavo RPi z usmerjevalnikom / brezžično dostopno točko ali Ethernet stikalom.

02) Operacijski sistem

https://downloads.raspberrypi.org/

Namestite operacijski sistem – PRENOS RASBIAN LINUX 32BIT TUKAJ
Ta stran opisuje prenos in namestitev operacijskega sistema, potrebnega za vaš Raspberry Pi. https://www.raspberrypi.org/
Za Raspberry Pi boste potrebovali kartico MicroSD z operacijskim sistemom. Kartico MicroSD lahko kupite na različnih komercialnih spletnih mestih z že nameščenim operacijskim sistemom, vendar je ni težko naložiti in namestiti sami, če ima vaš domači računalnik bralnik SD.
Če želite sami namestiti operacijski sistem, prenesite najnovejšo datoteko Raspbian iz: https://www.raspberrypi.org/downloads/raspberry-pi-os/
Lahko prenesete NOOBS in ga namestite na kartico SD. NOOBS je namestitveni program operacijskega sistema, ki nekoliko olajša postopek namestitve. Lahko pa prenesete sliko Raspbian in jo namestite na kartico SD kar je po mojem najbolje minimal install = image Rasbian lite!!!!!

Oblikovanje kartice SD
Če je bila kartica SD uporabljena že prej, jo boste morali formatirati, preden boste kar koli drugega storili. Če želite formatirati kartico SD v računalniku z operacijskim sistemom Windows, lahko uporabite format pomnilniške kartice SD, ki ga lahko prenesete od tukaj:
https://www.sdcard.org/downloads/formatter/ ali po moje je najbolje Rufus!!!!
Opomba: Pri uporabi tega pripomočka bodite previdni, saj lahko v računalniku formatirate napačen pogon.
Nameščanje NOOBS
Razširite datoteko za prenos, da dobite datoteke za kartico SD, nato pa jih s pomočjo raziskovalca datotek kopirajte na kartico SD. Izvlečene datoteke so lahko znotraj mape, v tem primeru kopirajte obrazec datotek znotraj mape in ne same mape.
Izvlecite kartico SD in jo vstavite v Raspberry Pi.
Ko vstavite kartico SD, pritrdite napajalnik, tipkovnico, miško in monitor – Raspberry Pi se bo zagnal. Izberite operacijski sistem Raspbian. Popeljal vas bo skozi vrsto nastavitvenih faz, ki bodo posodobile programsko opremo na najnovejšo različico, in vam zastavile različna vprašanja o zahtevani konfiguraciji za jezikovne nastavitve, vrsto tipkovnice itd.
Namestitev Raspbian iz prenosa
Raspbian lahko namestite neposredno na vaš Raspberry Pi, namesto da namestite prek NOOBS.
Za kartico SD potrebujete programsko opremo za slikanje.
Win32DiskImager je običajna izbira za osebni računalnik z operacijskim sistemom Windows in ga lahko prenesete iz:
http://sourceforge.net/projects/win32diskimager/
ali bolje
https://rufus.ie/

Prenesite npr. Win32DiskImager in razpakirajte datoteko ali bolje je Rufus po moje. Datoteko exe lahko zaženete celo iz pogona USB ali naložite Rufus in jo odprete.
Prenesite Raspbian in za dostop do slike razpakirajte preneseno datoteko.
Morda boste morali najprej formatirati kartico SD. Ko je formatiran, lahko z Win32DiskImager zapišete sliko Raspbian na kartico SD.
Izberite slikovno datoteko, ki ste jo izvlekli, in v polju naprave izberite črko pogona kartice SD.
Prepričajte se, da ste izbrali pravilno črko pogona.
Kliknite Write in počakajte, da se slika zapiše na kartico SD.
Zaprite programsko opremo za preslikovanje, odstranite kartico SD in jo vstavite v Raspberry Pi.

ZAPEČITE NAJNOVEJŠI OS RASPBIAN = https://www.raspberrypi.com/software/operating-systems/

obvezno minimal install os !!!

03) V računalniku Win ali MACu nastavite povezavo z oddaljenim namizjem (po izbiri – boljša varianta WebMin)

Ta stran oz. poglavje opisuje, kako namestite in nastavite oddaljeno namizje na Raspberry Pi, tako da lahko dostopate do svojega Pi, ne da bi ga povezali z monitorjem, tipkovnico ali miško.
Zaženite svoj Pi
Priključite tipkovnico USB, miško USB in s kablom HDMI povežite monitor z Raspberry Pi.
Napajalnik priključite na Raspberry Pi in se prepričajte, da je kartica MicroSD na mestu.
Priključite svoj Ethernet kabel na Raspberry Pi.
Vklopite Raspberry Pi.
Nato se Raspberry Pi zažene.
Privzeto uporabniško ime in geslo je uporabniško ime pi z geslom raspberry.
Nastavite povezavo z oddaljenim namizjem
Povezava z oddaljenim namizjem vam omogoča nadzor vašega Pi-ja iz osebnega računalnika, kot da bi bil fizično povezan z računalnikom. To pomeni, da lahko odpravite povezave monitorja HDMI, miške in tipkovnice.
Xrdp se mi zdi dober način za to, čeprav se nekateri uporabniki raje odločijo za brezglavo in popolnoma odstranijo grafični uporabniški vmesnik po mojem najbvoljši način. Nato se povežite v Pi s pomočjo SSH. Neuporaba grafičnega uporabniškega vmesnika ima lahko prednosti, ker bi lahko imeli potem dostop do več pomnilnika. Vendar se mi zdi uporaba GUI veliko bolj priročna. Jaz bi se odločil po moje, če bi nameščal Scado na PI vsekakor minimal install, in ob prvem zagonu povezava SSH ter v nastavitvah raspi-config bi za GPU v advance nastavitvah dal 16 Rama!!! Ne pozavite ob prvem zagonu localization odkljukajte poleg GB utf8 še SL_SI_UTF8 in uni spodnji SL_SI…….
Če se želite povezati z Raspberry Pi iz oddaljenega računalnika, lahko na Pi namestimo xrdp in se nato iz računalnika samo povežemo z njegovim naslovom ip.
Najprej namestite xrdp z uporabo naslednjega, ko ste v terminalu:

sudo apt install xrdp

Poiščite ip naslov vašega Raspberry Pi z naslednjim ukazom v terminalu:

ifconfig

Poiščite eth0, ob predpostavki, da ste z lokalnim omrežjem povezani z eth0, in videli bi naslov IP, ki bo v obliki lahko pa tudi wlan oz. wifi po želji:

192.168.1.82

Zdaj lahko v sistemu Windows/MacBook ali PC nastavite novo povezavo z oddaljenim namizjem.
Na namizju ustvarite novo datoteko z razširitvijo .rdp.
Ustvarjanje datoteke rdp v računalniku
Z desno miškino tipko kliknite novo ustvarjeno datoteko .rdp in izberite Uredi.

V polje za vnos računalnika vnesite ip naslov vašega Raspberry Pi in vnesite tudi uporabniško ime, ki je v tem primeru pi.
Če to shranite in nato dvokliknete datoteko .rdp, vam bo omogočila povezavo z vašim Raspberry Pi in prijavo z uporabniškim imenom pi in geslom raspberry.
Raspberry Pi bo zdaj šel skozi vrsto zaslonov za konfiguracijo, ki so precej naravnost naprej.
Ko končate z nastavitvijo in namestitvijo najnovejših posodobitev, lahko odpravite priključke tipkovnice, miške in HDMI na Raspberry Pi in do Pi boste lahko dostopali od koder koli v lokalnem omrežju.

04) Konfigurirajte Raspberry Pi

Obstaja nekaj stvari, ki jih moramo nastaviti kot del osnovne konfiguracije Raspberry Pi. Za to raje uporabljam vmesnik GUI, ki je na daljavo povezan z računalnikom Pi.
Na zaslonu menija bi morali videti Nastavitve -> Konfiguracija Raspberry Pi. Kliknite na to, da se prikaže zaslon konfiguracije.
Druga metoda je uporaba pripomočka za konfiguracijo Raspberry Pi iz terminala z vnosom:

sudo raspi-config

Ta ima nekoliko naprednejše funkcije, ki jih boste morda želeli spremeniti.
Spremenite geslo Pi npr. v pi to samo začasno dokler ne uštimamo vse!!! Jaz rajši osebno delam preko terminala program putty oz. jaz uporabljam SMARTFTP – TA PROGRAM BOSTE DOBIL V DDL ENIGMA (DOŽIVLJENSKA LICENCA!!!)
Spremenite gesloPassword za privzeto uporabniško ime pi v nekaj drugega, da izboljšate raven varnosti, če boste uporabljali račun pi, ma jaz vam to odsvetujem, samo za začetek za lažje delo spremenite geslo za uporabnika pi namesto raspberry geslo dajte v pi.
Spremenite ime gostitelja – hostname – raspberry v vaše karkoli npr. webscada!!!
Preklopite na nekaj bolj primernega, kot je npr. v tem primeru za webscado v “webscada” ali “mojascada” po vaši izbiri.
Preverite nastavitve vmesnikovInterfaces settings
Pojdite na zavihek vmesnika “interface” in preverite, ali so vsi vmesniki onemogočeni se pravi enable SSH!!!
Običajno uporabljamo povezavo z oddaljenim namizjem, če pa uporabljate SSH, se prepričajte, da je SSH omogočen – po mojem je to najboljša varianta, po želji sami se odločite ali boste delali preko terminala SSH ali Oddaljenega Namizja xrdp.
Posodobite svoje lokalne nastavitve – Se pravi Jazik ne pozabit odkljukat sl_si_UTF8 in še tistega spodaj ali važno je ta je ta sl si utf 8 odkljukan!
Poskrbite, da bosta vaša lokacija in časovni pas pravilno nastavljeni.
Shranite konfiguracijo in znova zaženite
Prepričajte se, da so spremembe shranjene, in znova zaženite Raspberry Pi.
Raspberry Pi lahko znova zaženete s terminala z uporabo:

sudo shutdown -r now

ali znova zaženite z uporabo:

sudo reboot

ali samo zaustavitev sistema z uporabo:

sudo shutdown -h now

Ko ste priklopi na TV vaš pi in tipkovnico se prijavli v terminal nastavite spodaj:

HOSTNAME MENJAJ V SVOJE NPR. webscada ali karkoli po vaši izbiri in za lažje delo na začetku menjajte password oz. geslo v pi in potrdi pi za lažje delo. Pol lahko ko končate samo zaklenete račun pi.

SSH ENABLE ! VLOLOPI


GPU ram spremeni iz 64 v 16

SPREMENI V NAŠO LOKACIJO UTF8 SL SI 

 

 

 

05) Raspberry Pi povežite z omrežjem in usmerjevalnikom

Zdaj, ko smo namestili Raspbian in končali osnovno konfiguracijo, lahko zdaj končamo s povezovanjem z vašim usmerjevalnikom.
Najprej povežite omrežje z Raspberry Pi in posodobite tako, da vnesete v terminalu (npr. putty ali SmartFTP):

sudo apt-get update

Nato nadgradite tako:

sudo apt-get upgrade

Zdaj lahko omrežje nastavimo tako, da Raspberry Pi uporablja fiksni naslov IP, ki se ob ponovnem zagonu usmerjevalnika ne spremeni (To obvezno v usmerjevalniku razervirajte oz. v vašem routerju).
Najprej poiščite naslov MAC in naslov IP vašega Raspberry Pi z ukazom:

ifconfig

Naslov MAC je enolična številka, dodeljena omrežnim vmesnikom – to je omrežni naslov, ki ga lahko uporabimo za povezavo z naslovom IP.
Naslov MAC bo videti nekako tako: b8:27:eb:ad:31:3c
Naslov IP bo videti nekako takole: 192.168.1.75
Ko dobite naslov MAC in IP, se morate prijaviti v usmerjevalnik. Nekje v menijskem sistemu bi morali najti naprave v svojem omrežju. To je seveda odvisno od vašega usmerjevalnika in morda boste morali poiskati dokumentacijo zanj. Vaš usmerjevalnik naj prikaže Raspberry Pi z imenom gostitelja, naslovom IP in MAC.
Če se na Raspberry Pi vedno sklicujete z imenom gostitelja, ne bo pomembno, ali se bo naslov IP spremenil.

Vklopite v usmerjevalniku DHCP IN ŠE REZERVIRAJTE LOKALNI IP NA BAZ MAC NASLOVA OD RASPBERRY PI!!! TAKO, ČE SE VAM UGASNE ROUTER OZ. USMERJEVALNIK NE BOSTE DOBILI NEK NOV IP ZA RASPBERRY ŠE POSEBEJ ČE STE POVEZANI PREKO WIFI NA RASPBERRY!!! POGLEJTE SI NASTAVITVE VAŠEGA USMERJEVALNIKA VSAK IMA MALO DRUGAČNE MENIJE MA FUNKCIONALNOSTI SO PRI VSEH USMERJEVALNIKIH ENAKE!
REZERVIRAJTE NA USMERJEVALNIKU OZ. VAŠEM ROUTERJU ZA VAŠ PI 4-3-2

ZDAJ LAHKO ŠE REZERVIRAMO V RASPBERRY PI ZVA VAŠ RASPBIAN LINUX IP, NPR. ČE GA IMATE Z KABLOM POVEZANEGA, ALI WIFI TAKO:

sudo nano /etc/dhcpcd.conf 

ČE JE PI 4-2-3 POVEZAN S KABLOM KOPIRAJTE SPODNJE DIREKTIVE ČISTO NA KONCU, SE PRAVI 192.168.1.1 JE IP ROUTERJA VI LAHKO IMATE TUDI 192.168.0.1 ODVISNO OD ROUTERJA OZ. USMERJEVALNIKA IN NPR. MOJ PI4 JE NA IPJU 192.168.1.82 – Kopirajte take direktive moj primer:

interface eth0
static ip_address=192.168.1.82/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8  

Zdaj, če imate vaš PI preko WiFi povezave pa vpišete tako:

interface wlan0
static ip_address=192.168.1.82/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8  

Često na koncu tam kjer je DNS od Google lahko s presledkom ločite še vaš DNS vašega ISP ponudnika npr. t-2.net ima ta dva IP DNS: 84.255.209.79 , 84.255.210.79 medtem, ko za telekom slovenije oz. siol vpišete 193.189.160.13 , 193.189.160.23 in ostali poglejte za vašega ISP!!!

Primer za t-2.net če imate vaš PI preko kabla povezan:

interface eth0
static ip_address=192.168.1.82/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 84.255.209.79 84.255.210.79 8.8.8.8 1.1.1.1

Za Google DNS sta ta dva 8.8.8.8 in 8.8.4.4 ter za CloudFlare sta ta dva 1.1.1.1 in 1.0.0.1 in poglejte še za Comodo, itd……

06) Ustvari novega uporabnika in izbriši uporabnika pi

V celoti moramo izbrisati obstoječega uporabnika »pi«, ker gre za varnostno težavo. Vsi vemo, da ima Raspberry Pi privzeto uporabniško ime “pi”, zato ga moramo nadomestiti – ZDAJ DOKLER NASTAVLJAMO JE OK PUSTITE AMAPK, NABOLJE JE DA GA IZBRIŠETE.
Če želite ustvariti novega uporabnika, uporabimo ukaz adduser, vendar moramo zagotoviti, da je novi uporabnik v isti skupini kot obstoječi uporabnik pi.
V terminal vnesite:

groups pi

ki bo seznam vseh skupin, v katerih je ta uporabnik se pravi PI. Rezultat bo videti približno tako:

pi adm dialout cdrom sudo audio video plugdev games users netdev input

We need to create a new user with the same group allocation.

Ustvariti moramo novega uporabnika z enakimi dodelitvami skupin.
Če želite ustvariti novega uporabnika, uporabite ukaz useradd s seznamom vseh kopiranih skupin z zgornjega seznama, skupina pi. V mojem primeru je videti tako, toda vaš bo videti nekoliko drugače:

sudo useradd -m -G adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,netdev,input <uporabnik>

npr. da generiramo uporabnika webscada naredite tako v terminalu:

sudo adduser webscada

Izpolnite Geslo, v terminal geslo kopirate z desnim miškinim kazalcem, pripravite si v namrej dokument oz. TXT datoteko z vašimi gesli in vsemi komandami, ki jih boste potrebovali ali iz te objave kopirajte vse potrebne kode!!!!!

sudo adduser webscada

# MENJAVA GESLA Z:
sudo passwd webscada

#npr. geslo:   mojawebscada1234koda
# VEDNO KADAR NPR. IZ TXT DATOTEKE IZ VAŠEGA RAČUNALNIKA KOPIRATE KARKOLI KODO NPT. CTRL+C JO PRILEPITE V TERMINAL Z LEVIM MIŠKINIM KAZALCEM KO KLIKNETE NA TERMINAL NPR. PUTTY ALI SMARTFTP IPD. SSH PROGRAMI OZ. SSH KLIJENT PROGRAMI!!!

dodeli webscada previce v terminalu tako, da zažete to komando:

sudo usermod -a -G adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,netdev,spi,i2c,gpio,www-data webscada

# LAHKO TUDI ZA VEČJE ŠTEVILO ADMIN OZ. UPORABNIKOV ČE STE JIH USTVARILI ZA VSAKEGA DAJTE PO ŽELJI DODELITEV PRAVIC, PREMER:

sudo usermod -a -G adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,netdev,spi,i2c,gpio uporabnik1

sudo usermod -a -G adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,netdev,spi,i2c,gpio uporabnik2

sudo usermod -a -G adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,netdev,spi,i2c,gpio uporabnik3

Zdaj gremo še določit v tem primeru uporabniku webscada, da je s-admin, da vam ne rabi pri komandi sudo su vpisovati gesla ponovno npr. v terminal kopirat kodo z desnim miškinim kazalcem:

sudo nano /etc/sudoers.d/010_pi-nopasswd

Zdaj vi zamenjajte pi v webscada:

webscada ALL=(ALL) NOPASSWD: ALL

Zdaj če ste ustvarili večje število uporabnikov in bi želeli, da v terminalu pri izvajanju kode sudo su ne potrebujete vpisati ponovno kode to storite tako:

sudo visudo

root    ALL=(ALL) ALL
## na koncu kopirajte npr. tako direktive:
webscada    ALL=(ALL) ALL
webscada    ALL = NOPASSWD: ALL
### to je že v /etc/sudoers.d/010_pi-nopasswd lahko tudi 
### dodate brez problemov še enkrat webscada

uporabnik1    ALL=(ALL) ALL
uporabnik1    ALL = NOPASSWD: ALL

uporabnik2    ALL=(ALL) ALL
uporabnik2    ALL = NOPASSWD: ALL

uporabnik3    ALL=(ALL) ALL
uporabnik3    ALL = NOPASSWD: ALL

# shrani in izhod

Ponovni zagon in prijava ne več v pi ampak z uporabniškim imenom webscada – Se pravi v Putty ali SmartFTP ali vaš priljubljen program SSH server, se povežete tako, da uporabite uporabniško ime webscada in vaše geslo:

sudo reboot

# Ali s komando ma zgorjna je lažja:
sudo shutdown -r now

Brisanje privzetega uporabnika »pi«
Zdaj lahko uporabnika pi izbrišemo z eno od teh komand sredinska je čisto dovolj zbriše vse datoteke od uporabnika pi:

sudo deluser pi

sudo userdel -r -f pi

sudo deluser -remove-home pi

Izvirnega uporabnika pi in z njim povezane datoteke je treba zdaj izbrisati.
Spremenite podrobnosti o povezavi z oddaljenim namizjem
Ne pozabite spremeniti podrobnosti o povezavi z oddaljenim namizjem, tako da se bo poskušalo prijaviti v novo ime gostitelja in geslo uporabniškega imena se pravi webscada uporabnik in vaše ime gostitelja, ki ste ga spremenili iz raspberry v karkoli.

webscada@hostname-ime-gostitelja-original-je-bilo-raspberry

nrp. zdaj ko ste prijavljeni z uporabnikom webscada in npr. ime gostitelja mojascada izgleda tako vaša prijava v terminal:

webscada@mojascada :~ $

ZDAJ BI LAHKO NAMESTILI ŠE NPR. CERTIFIKAT SSH IN GA SKONFIGURIRALI, MA NE RABI, KER NE BOMO POSREDOVALI PORTOV SSH OZ. PORTA 22:

sudo nano /etc/ssh/sshd_config

NA KONCU KOPIRAJTE NPR. TAKO:

AllowUsers  webscada uporabnik1 uporabnik2 uporabnik3

Medtem ko boste SSH ključ generirali če ste terminal zavarovali z SSH certifikatom tako (nastavitve sshd_config) samo za info:

sudo su - webscada
ssh-keygen

sudo su - uporabnik1

sudo su - uporabnik2
ssh-keygen

sudo su - uporabnik3
ssh-keygen

 

07) Nastavite požarni zid – FireWall linux

Na tej strani oz. poglavju je opisano, kako nastaviti pravila požarnega zidu za blokiranje neželenega prometa na Raspberry Pi.
iptables je krmilnik za netfilter in iptables je vključen v distribucijo Raspberry Pi – Rasbian Linux 10 je derivat Debian Buster 10 Linux. Pozor za tiste, ki nameščate višje različice RPI-10+ se pravi Bullseye Debian 11 oz. raspbian 11 linux, ne pozabit ko ste na začetku nadgradili celoten sistem namestit še iptables / (sudo apt install iptables)

Po meni iptables oz. požarni zid za WEB Scada – Roborina.si
Obstaja več konfiguracijskih sistemov, s katerimi lahko lažje delate z iptables, vendar ne bomo ustvarili veliko pravil, zato bomo lahko ustvarili nabor pravil in nato uvozili nabor pravil v iptables. Pravila, ki jih opisujemo, so posebej za spletni strežnik in vaše zahteve se lahko razlikujejo od tega primera.
Trenutna pravila lahko prikažete z naslednjimi ukazi:
IPv4:

sudo iptables -L

IPv6:

sudo ip6tables -L

iptables privzeto nima pravil za IPv4 in IPv6, zato boste sprva videli brez pravil požarnega zidu. To pomeni, da je dovoljen ves dohodni, posredovani in odhodni promet – vse je odklenjeno. Dohodni in preusmerjeni promet moramo omejiti le na tisto, kar je potrebno. /(če nimate ipv6 povezave lahko to komot izklopite!!!)

Chain INPUT (policy ACCEPT)
target prot opt source destinationChain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Ustvarjanje nabora pravil požarnega zidu
Kot primer, naslednje ustvarja nabor pravil za IPV4 in IPV6. Primeri so osnovni nabor pravil, ki ga bo morda treba spremeniti glede na vaše posebne sistemske zahteve.
Ustvari novo datoteko v npr. mapi tmp, ki sem jo imenoval V4:

sudo nano /tmp/v4

# Pripravil sem vam tudi že narejeno datoteko za iptables:
/etc/iptables.up.rules PRENESITE IZ TEGA STREŽNIKA IN LAHKO NAMESTO GENERIRAT PRAVILA UPORABITE MOJA SEM VAM VSE ŽE PRIPRAVIL!

Kopirajte naslednje oz. spodnje direktive v to datoteko in jo shranite npr. z CTRL+O ali CTRL+X in Shranite Yes – DA za datoteko /tmp/v4!!!. KOPIRAJ SPODNJE DIREKTIVE V SVOJO DATOTEKO /tmp/v4:

# Generated for iptables-webmin-custom-settings by homecraftsoft.com on Mon jul 29 12:06:00 2020
*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
# Completed on Mon jul 29 12:06:00 2020
*raw
:PREROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
COMMIT
*mangle
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
# Completed on Mon jul 29 12:06:00 2020
# Generated for iptables-webmin-custom-settings by homecraftsoft.com on Mon jul 29 12:06:00 2020
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT DROP [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT
-A INPUT -d 127.0.0.0/8 -j REJECT --reject-with icmp-port-unreachable
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A INPUT ! -i eth0 -j ACCEPT
-A INPUT -p tcp -m tcp --tcp-flags ACK ACK -j ACCEPT
# Accept responses to port 8442 Cybrotech controllers queries
-A INPUT -p udp -m udp --dport 1024:65535 --sport 8442 -j ACCEPT
# Accept responses to our pings
-A INPUT -p icmp -m icmp --icmp-type echo-reply -j ACCEPT
# Accept notifications of unreachable hosts
-A INPUT -p icmp -m icmp --icmp-type destination-unreachable -j ACCEPT
# Accept notifications to reduce sending speed
-A INPUT -p icmp -m icmp --icmp-type source-quench -j ACCEPT
# Accept notifications of lost packets
-A INPUT -p icmp -m icmp --icmp-type time-exceeded -j ACCEPT
# Accept notifications of protocol problems
-A INPUT -p icmp -m icmp --icmp-type parameter-problem -j ACCEPT
# Allow connections to our SSH server
-A INPUT -p tcp -m tcp -m multiport -j ACCEPT --dports ssh,www,https,pop3,smtp,imap,imaps,pop3s,10000,4000,8442
# Allow connections to our IDENT server
-A INPUT -p tcp -m tcp --dport auth -j ACCEPT
# Respond to pings
-A INPUT -p icmp -m icmp --icmp-type echo-request -j ACCEPT
# Protect our NFS server
-A INPUT -p tcp -m tcp --dport 2049:2050 -j DROP
# Protect our X11 display server
-A INPUT -p tcp -m tcp --dport 6000:6063 -j DROP
# Protect our X font server
-A INPUT -p tcp -m tcp --dport 7000:7010 -j DROP
# Allow connections to unprivileged ports
#-A INPUT -p tcp -m tcp --dport 1024:63353 -j ACCEPT
# Accept traceroutes
-A INPUT -p udp -m udp --dport 8442:65535 -j ACCEPT
# Completed on Mon jul 29 12:06:00 2020 Generated for iptables-webmin-custom-settings by homecraftsoft.com on Mon jul 29 12:06:00 2020 Allows all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
# WEBMail email ports allow - Spletna poša porti tega ne rabite če ne mislite uporabljat epošte!!!
-A INPUT -p tcp --dport 25 -j ACCEPT
-A INPUT -p tcp --dport 465 -j ACCEPT
-A INPUT -p tcp --dport 587 -j ACCEPT
-A INPUT -p tcp --dport 143 -j ACCEPT
-A INPUT -p tcp --dport 993 -j ACCEPT
-A INPUT -p tcp --dport 110 -j ACCEPT
-A INPUT -p tcp --dport 995 -j ACCEPT
# WEBmin in Cybrotech scgi server
-A INPUT -p tcp --dport 4000 -j ACCEPT
-A INPUT -p tcp --dport 8442 -j ACCEPT
-A INPUT -p tcp --dport 10000 -j ACCEPT
COMMIT
# Completed on Mon jul 29 12:06:00 2020

Ustvari novo datoteko v mapi tmp, ki sem jo imenoval V6:

sudo nano /tmp/v6

Kopirajte naslednje v to datoteko in jo shranite – tega ne rabite za Slovenijo:

# Generated for iptables-webmin-custom-settings by homecraftsoft.com on Mon jul 29 12:55:21 2020
*nat
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
COMMIT
# Completed on Mon jul 29 12:55:21 2020
*raw
:PREROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
COMMIT
*mangle
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
# Completed on Mon jul 29 12:55:21 2020
# Generated for iptables-webmin-custom-settings by homecraftsoft.com on Mon jul 29 12:55:21 2020
*filter
:FORWARD ACCEPT [0:0]
:INPUT DROP [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -i lo -j ACCEPT
# Dissalow input - connections from outsite localhost
-A INPUT -s ::1/128 ! -i lo -j REJECT
# Accept traffic from internal interfaces
-A INPUT ! -i eth0 -j ACCEPT
# Accept traffic with the ACK flag set
-A INPUT -p tcp -m tcp --tcp-flags ACK ACK -j ACCEPT
# Allow incoming data that is part of a connection we established
-A INPUT -m state --state ESTABLISHED -j ACCEPT
# Allow data that is related to existing connections
-A INPUT -m state --state RELATED -j ACCEPT
# Accept responses to DNS queries UPD connedtion port ipv4 8442 open all ports from 1024 to 65535
-A INPUT -p udp -m udp --dport 1024:65535 --sport 8442 -j ACCEPT
#-A INPUT -p udp -m udp --dport 1024:65535 --sport 8442 -j ACCEPT
-A INPUT -p tcp -m tcp -m multiport -j ACCEPT --dports ftp,ssh,www,https,pop3,smtp,imap,imaps,pop3s,8338,4000,10000
## Allow connections to our IDENT server
-A INPUT -p tcp -m tcp --dport auth -j ACCEPT
# Respond to pings -A INPUT -p icmp -m icmp --icmp-type echo-request -j ACCEPT Protect our NFS server
-A INPUT -p tcp -m tcp --dport 2049:2050 -j DROP
# Protect our X11 display server
-A INPUT -p tcp -m tcp --dport 6000:6063 -j DROP
# Protect our X font server
-A INPUT -p tcp -m tcp --dport 7000:7010 -j DROP
-A INPUT -j REJECT
-A FORWARD -j REJECT
COMMIT
# Completed IPTables Custom Config

Naložite iptable pravila
Za nalaganje iptable uporabljamo ukaze:

sudo iptables-restore < /tmp/v4

sudo ip6tables-restore < /tmp/v6

Potrebujemo način, da zagotovimo, da so pravila iptable na voljo po ponovnem zagonu, zato moramo namestiti iptables-persistent z uporabo:

sudo apt-get install iptables-persistent ipset

Vprašani boste, ali želite shraniti trenutna pravila IPv4 in IPv6. Na vsak poziv odgovorite z da – YES!!!.
Če želite, lahko odstranite začasni datoteki v4 in v6.
Pravila požarnega zidu lahko ponovno preverimo z uporabo komande:

sudo iptables -vL

sudo ip6tables -vL

To so osnovna pravila požarnega zidu. Vendar boste morda morali ta pravila urediti, če se namestitev na primer spremeni v datoteki strežnika.

VSE GLEDE IPTABLES SE PRAVI LINUX POŽARNEGA ZIDU BOSTE DOBILI NA STRANI DEBIAN VSE DIREKTIVE VELJAJO TUDI ZA RASBIAN!!!

https://www.debian.org/

PS: SORRY AMPAK JAZ PIŠEM VSE MOJE PROGRAME V ANGLEŠČINI IN TO VELJA TUDI ZA RAZLAGE TAKO DA BREZ ZAMERE – PRI RAZVOJU LASTNIH SPLETNIH APLIKACIJ MI POMAGAJO PRIJATELJI IZ TUJINE TAKO DA NE MOREM PISATI V SLOVENŠČINI NOBENE RAZLAGE, KONEC KONCEV JE STANDARDNI JEZIK ZA ITS ZAME ANGLEŠČINA, ŠE WINDOWSA IN NOBENEGA PROGRAMA NIMAM V SL-SI SLOVENSKEM JEZIKU STVAR NAVADE.

PRENESITE SI MOJE IPTABLES IZKLJUČNO ZA RASPBERRY PI,  KI SEM JIH PRIPRAVIL ZA VAS UPORABNIKE PCSNET OZ. HTU IN UITW ORG. EU  PREKO TEGA URL – https://perc.ddns.net/ddl/download.php:

Če ste si prenesli moje datoteke iptables, pa naredite tako, lahko npr. ustvarite pravila požarnega zidu tako – kopirajte direktive iz datotek, ki sem jih pripravil – iptables požarni zid linux – webmin config dve datoteke zip in jih npr. namestite v mapo /etc/ bolje zaradi tega ker sem vam pripravil večje število direktiv ene so enake zato pazite kaj odkomentirate:

sudo nano /etc/iptables.up.rules

Kopirajte vse direktive iz moje datoteke iptables.up.rules ki ste jo prenesli in odzipali na vaš računalnik ter to velja še za:

sudo nano /etc/ip6tables.up.rules

Kopirajte direktive iz moje datoteke za ip6tables.up.rules in namestite tako:

sudo iptables-restore < /etc/iptables.up.rules

sudo ip6tables-restore < /etc/ip6tables.up.rules

sudo apt-get install iptables-persistent -y

sudo reboot

sudo iptables -vL

sudo ip6tables -vL

webscada@mojascada:~ $ sudo iptables -vL
Chain INPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
216K 163M ACCEPT all — lo any anywhere anywhere
0 0 REJECT all — !lo any anywhere 127.0.0.0/8 reject-with icmp-port-unreachable
0 0 REJECT all — any any anywhere 127.0.0.0/8 reject-with icmp-port-unreachable
142K 65M ACCEPT all — any any anywhere anywhere state RELATED,ESTABLISHED
0 0 ACCEPT all — any any anywhere anywhere ctstate RELATED,ESTABLISHED
0 0 ACCEPT all — !eth0 any anywhere anywhere
0 0 ACCEPT tcp — any any anywhere anywhere tcp flags:ACK/ACK
1178 68660 ACCEPT tcp — any any anywhere anywhere ctstate NEW,ESTABLISHED tcp dpt:http
0 0 ACCEPT tcp — any any anywhere anywhere ctstate NEW,ESTABLISHED tcp dpt:https
0 0 ACCEPT tcp — any any anywhere anywhere ctstate NEW,ESTABLISHED tcp dpt:ftp
0 0 ACCEPT tcp — any any anywhere anywhere ctstate NEW,ESTABLISHED tcp dpt:smtp
0 0 ACCEPT tcp — any any anywhere anywhere ctstate NEW,ESTABLISHED tcp dpt:imap2
0 0 ACCEPT tcp — any any anywhere anywhere ctstate NEW,ESTABLISHED tcp dpt:imaps
0 0 ACCEPT tcp — any any anywhere anywhere ctstate NEW,ESTABLISHED tcp dpt:pop3
0 0 ACCEPT tcp — any any anywhere anywhere ctstate NEW,ESTABLISHED tcp dpt:pop3s
41 2132 ACCEPT tcp — any any anywhere anywhere ctstate NEW,ESTABLISHED tcp dpt:8338
1 40 ACCEPT tcp — any any anywhere anywhere ctstate NEW,ESTABLISHED tcp dpt:8442
0 0 ACCEPT tcp — any any anywhere anywhere ctstate NEW,ESTABLISHED tcp dpt:4000
2542 141K ACCEPT tcp — any any anywhere anywhere ctstate NEW,ESTABLISHED tcp dpt:webmin
3685 325K ACCEPT all — any any 192.168.0.0/16 anywhere
0 0 ACCEPT all — any any 192.168.1.0/24 anywhere
0 0 ACCEPT all — any any 192.168.1.111 anywhere
0 0 ACCEPT all — any any 192.168.1.222 anywhere
0 0 ACCEPT all — any any 192.168.1.77 anywhere
0 0 ACCEPT all — any any 192.168.1.123 anywhere
0 0 ACCEPT tcp — any any anywhere anywhere tcp multiport dports ftp,ssh,http,https,smtp,pop3,imap2,submission,imaps,pop3s,4000,8442,8338,webmin
0 0 ACCEPT all — wlan0 any anywhere anywhere
10 1564 ACCEPT all — eth0 any anywhere anywhere
0 0 ACCEPT tcp — any any anywhere anywhere state NEW tcp dpt:ssh
0 0 ACCEPT tcp — any any 192.168.1.222 anywhere state NEW,RELATED,ESTABLISHED tcp dpt:ssh
0 0 DROP tcp — any any anywhere anywhere state NEW,RELATED,ESTABLISHED tcp dpt:ssh
0 0 ACCEPT tcp — any any anywhere anywhere tcp dpt:ftp
0 0 ACCEPT tcp — any any anywhere anywhere tcp dpt:smtp
0 0 ACCEPT tcp — any any anywhere anywhere tcp dpt:http
0 0 ACCEPT tcp — any any anywhere anywhere tcp dpt:pop3
0 0 ACCEPT tcp — any any anywhere anywhere tcp dpt:imap2
0 0 ACCEPT tcp — any any anywhere anywhere tcp dpt:https
0 0 ACCEPT tcp — any any anywhere anywhere tcp dpt:submissions
0 0 ACCEPT tcp — any any anywhere anywhere tcp dpt:submission
0 0 ACCEPT tcp — any any anywhere anywhere tcp dpt:imaps
0 0 ACCEPT tcp — any any anywhere anywhere tcp dpt:pop3s
0 0 ACCEPT tcp — any any anywhere anywhere tcp dpt:4000
0 0 ACCEPT tcp — any any anywhere anywhere tcp dpt:8442
0 0 ACCEPT tcp — any any anywhere anywhere tcp dpt:8338
0 0 ACCEPT tcp — any any anywhere anywhere tcp dpt:webmin
0 0 ACCEPT udp — any any anywhere anywhere state NEW,ESTABLISHED udp dpt:8442
0 0 ACCEPT udp — any any anywhere anywhere state NEW,ESTABLISHED udp dpt:domain
0 0 ACCEPT udp — any any anywhere anywhere udp spt:8442 dpts:1024:65535
0 0 ACCEPT udp — any any anywhere anywhere udp spt:domain
0 0 ACCEPT tcp — any any 192.168.0.0/16 anywhere ctstate NEW,ESTABLISHED tcp dpt:mysql
0 0 ACCEPT tcp — any any 192.168.1.0/24 anywhere ctstate NEW,ESTABLISHED tcp dpt:mysql
0 0 ACCEPT tcp — any any 192.168.1.77 anywhere ctstate NEW,ESTABLISHED tcp dpt:mysql
0 0 ACCEPT tcp — any any 192.168.1.222 anywhere ctstate NEW,ESTABLISHED tcp dpt:mysql
0 0 ACCEPT tcp — any any 192.168.1.111 anywhere ctstate NEW,ESTABLISHED tcp dpt:mysql
0 0 ACCEPT tcp — any any 192.168.1.123 anywhere ctstate NEW,ESTABLISHED tcp dpt:mysql
0 0 ACCEPT tcp — eth0 any anywhere anywhere ctstate NEW,ESTABLISHED tcp dpt:mysql
0 0 ACCEPT tcp — any any 192.168.0.0/16 anywhere ctstate NEW,ESTABLISHED tcp dpt:postgresql
0 0 ACCEPT tcp — any any 192.168.1.0/24 anywhere ctstate NEW,ESTABLISHED tcp dpt:postgresql
0 0 ACCEPT tcp — eth0 any anywhere anywhere ctstate NEW,ESTABLISHED tcp dpt:postgresql
0 0 ACCEPT tcp — any any anywhere anywhere tcp dpt:3142
0 0 ACCEPT tcp — any any anywhere anywhere ctstate NEW,ESTABLISHED tcp dpt:ssh
0 0 ACCEPT tcp — any any anywhere anywhere ctstate ESTABLISHED tcp spt:ssh
0 0 ACCEPT tcp — any any anywhere anywhere state NEW tcp dpt:ssh
0 0 ACCEPT tcp — any any anywhere anywhere tcp dpt:ssh
0 0 ACCEPT tcp — any any 192.168.1.222 anywhere tcp dpt:ssh
0 0 DROP tcp — any any anywhere anywhere tcp dpt:ssh
0 0 ACCEPT tcp — any any anywhere anywhere tcp dpt:http limit: avg 20/min burst 100
0 0 ACCEPT tcp — any any 192.168.0.0/16 anywhere ctstate NEW,ESTABLISHED tcp dpt:rsync
0 0 ACCEPT tcp — any any 192.168.1.0/24 anywhere ctstate NEW,ESTABLISHED tcp dpt:rsync
0 0 ACCEPT udp — any any anywhere anywhere state NEW udp dpt:mdns
0 0 ACCEPT icmp — any any anywhere anywhere icmp echo-request
0 0 ACCEPT tcp — any any anywhere anywhere tcp dpt:auth
0 0 ACCEPT udp — any any anywhere anywhere state NEW udp dpt:ntp
0 0 DROP tcp — any any anywhere anywhere tcp dpts:nfs:2050
0 0 DROP tcp — any any anywhere anywhere tcp dpts:x11:6063
0 0 DROP tcp — any any anywhere anywhere tcp dpts:afs3-fileserver:7010
0 0 LOG all — any any anywhere anywhere limit: avg 5/min burst 5 LOG level debug prefix “iptables denied: “
0 0 DROP all — any any anywhere anywhere ctstate INVALID
0 0 REJECT all — any any anywhere anywhere reject-with icmp-port-unreachable
0 0 DROP all — any any anywhere anywhere
0 0 ACCEPT all — any any anywhere anywhere state RELATED,ESTABLISHED
0 0 DROP all — any any anywhere anywhere state INVALID

Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 REJECT all — any any anywhere anywhere reject-with icmp-port-unreachable
0 0 DROP all — any any anywhere anywhere
0 0 ACCEPT all — wlan0 eth0 anywhere anywhere state RELATED,ESTABLISHED
0 0 ACCEPT all — eth0 wlan0 anywhere anywhere
0 0 ACCEPT all — eth0 wlan0 anywhere anywhere state RELATED,ESTABLISHED
0 0 ACCEPT all — wlan0 eth0 anywhere anywhere
0 0 ACCEPT all — eth0 any anywhere anywhere state RELATED,ESTABLISHED

Chain OUTPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
325K 222M ACCEPT all — any any anywhere anywhere state RELATED,ESTABLISHED
114 7210 ACCEPT udp — any any anywhere anywhere udp dpt:domain
0 0 ACCEPT udp — any any anywhere dns.google udp dpt:domain
0 0 ACCEPT udp — any any anywhere dns.google udp dpt:domain
0 0 ACCEPT udp — any any anywhere dnslj1.t-2.net udp dpt:domain
0 0 ACCEPT udp — any any anywhere dnsmb1.t-2.net udp dpt:domain
0 0 ACCEPT all — any any anywhere anywhere ctstate ESTABLISHED
22428 1566K ACCEPT all — any any anywhere anywhere
0 0 ACCEPT udp — any any anywhere anywhere udp multiport dports ntp state NEW
0 0 ACCEPT tcp — any any anywhere anywhere ctstate ESTABLISHED tcp spt:http
0 0 ACCEPT tcp — any any anywhere anywhere ctstate ESTABLISHED tcp spt:https
0 0 ACCEPT tcp — any any anywhere anywhere ctstate ESTABLISHED tcp spt:ftp
0 0 ACCEPT tcp — any any anywhere anywhere ctstate ESTABLISHED tcp spt:smtp
0 0 ACCEPT tcp — any any anywhere anywhere ctstate ESTABLISHED tcp spt:imap2
0 0 ACCEPT tcp — any any anywhere anywhere ctstate ESTABLISHED tcp spt:imaps
0 0 ACCEPT tcp — any any anywhere anywhere ctstate ESTABLISHED tcp spt:pop3
0 0 ACCEPT tcp — any any anywhere anywhere ctstate ESTABLISHED tcp spt:pop3s
0 0 ACCEPT tcp — any any anywhere anywhere ctstate ESTABLISHED tcp spt:mysql
0 0 ACCEPT tcp — any any anywhere anywhere ctstate ESTABLISHED tcp spt:4000
0 0 ACCEPT tcp — any any anywhere anywhere ctstate ESTABLISHED tcp spt:8442
0 0 ACCEPT tcp — any any anywhere anywhere ctstate ESTABLISHED tcp spt:8338
0 0 ACCEPT tcp — any any anywhere anywhere ctstate ESTABLISHED tcp spt:webmin
0 0 ACCEPT tcp — any eth0 anywhere anywhere ctstate ESTABLISHED tcp spt:mysql
0 0 ACCEPT tcp — any any anywhere anywhere ctstate ESTABLISHED tcp spt:postgresql
0 0 ACCEPT tcp — any eth0 anywhere anywhere ctstate ESTABLISHED tcp spt:postgresql
0 0 ACCEPT tcp — any any anywhere anywhere ctstate ESTABLISHED tcp spt:ssh
0 0 ACCEPT tcp — any any anywhere anywhere ctstate NEW,ESTABLISHED tcp dpt:ssh
0 0 ACCEPT tcp — any any anywhere anywhere ctstate ESTABLISHED tcp spt:rsync
0 0 ACCEPT all — any any anywhere 192.168.0.0/16
0 0 ACCEPT all — any any anywhere 192.168.1.0/24
0 0 ACCEPT all — any any anywhere 192.168.1.77
0 0 ACCEPT all — any any anywhere 192.168.1.111
0 0 ACCEPT all — any any anywhere 192.168.1.123
0 0 ACCEPT all — any any anywhere 192.168.1.222
0 0 ACCEPT tcp — any any 192.168.1.222 anywhere tcp dpt:ssh
0 0 DROP tcp — any any anywhere anywhere tcp dpt:ssh

Chain block-scan (0 references)
pkts bytes target prot opt in out source destination
0 0 RETURN tcp — any any anywhere anywhere tcp flags:FIN,SYN,RST,ACK/RST limit: avg 1/sec burst 5
0 0 DROP all — any any anywhere anywhere
webscada@sandinetworkizola:~ $ sudo ip6tables -vL
Chain INPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
1239 124K ACCEPT all lo any anywhere anywhere
0 0 REJECT all !lo any localhost anywhere reject-with icmp6-port-unreachable
0 0 ACCEPT all !eth0 any anywhere anywhere
0 0 ACCEPT tcp any any anywhere anywhere tcp flags:ACK/ACK
0 0 ACCEPT all any any anywhere anywhere state ESTABLISHED
0 0 ACCEPT all any any anywhere anywhere state RELATED
0 0 ACCEPT udp any any anywhere anywhere udp spt:8442 dpts:1024:65535
0 0 ACCEPT tcp any any anywhere anywhere tcp multiport dports ftp,ssh,http,https,pop3,smtp,imap2,imaps,pop3s,4000,8442,8338,webmin
0 0 ACCEPT tcp any any anywhere anywhere tcp dpt:auth
0 0 DROP tcp any any anywhere anywhere tcp dpts:nfs:2050
0 0 DROP tcp any any anywhere anywhere tcp dpts:x11:6063
0 0 DROP tcp any any anywhere anywhere tcp dpts:afs3-fileserver:7010
352 95207 REJECT all any any anywhere anywhere reject-with icmp6-port-unreachable

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 REJECT all any any anywhere anywhere reject-with icmp6-port-unreachable

Chain OUTPUT (policy ACCEPT 1239 packets, 124K bytes)
pkts bytes target prot opt in out source destination
webscada@mojascada:~ $

 

8) Namestite Apache2 na Raspberry Pi

Namestitev spletnega strežnika Apache na Raspberry Pi mora biti neposredna. To predpostavlja, da ste za Raspberry Pi nastavili ime gostitelja in da je povezani z vašim lokalnim omrežjem.
Prijavite se na Raspberry Pi s pomočjo terminala in vnesite:

sudo apt update

# ali kar to spodaj direktivo kopirajte v terminal:

sudo apt update && sudo apt upgrade -y

Namestitev Apache 2 strežnika:

sudo apt-get install apache2 -y

# ali s to komando še za pripomočke:
sudo apt-get install apache2 apache2-utils -y

Preizkusite spletni strežnik
Apache privzeto postavi preskusno datoteko HTML v spletno mapo, ki si jo boste lahko ogledali iz svojega Pi ali iz drugega računalnika v omrežju.
Odprite privzeto spletno stran Apache na Raspberry Pi s pomočjo spletnega brskalnika na Raspberry Pi in vnesite http://mojascada oz. vaše ime gostitelja ki ste ga določili (raspberry npr. webscada@mojascada :~ $)
Videti bi morali privzeto stran Apache2 Debian.
Poskusite namesto localhost PI, ki ste ga določiti uporabiti kar IP za Raspberry Pi vaše lokalno omrežje. Na primer, moje ime gostitelja je mojascada, zato namesto tega bom uporabil http://ipraspberry v mojem primeru je http://192.168.1.82.
Lahko v vaše spletnem brskalniku uporabite ali eno ali drugo po želji.
Če želite poiskati naslov IP vašega Raspberry Pi, v terminal vnesite naslednje:

hostname -I

Spreminjanje privzete spletne strani
Privzeta spletna stran je samo datoteka HTML v datotečnem sistemu. Nahaja se na /var/www/html/index.html.
Če želite spremeniti to datoteko:

sudo nano /var/www/html/index.html

Vendar mi tega ne potrebujemo zato jo lahko kar izbrišemo tako:

cd /var/www/html/

webscada@mojascada:/var/www/html $

## in za ibris te datoteke ali vse zažkite to komando:
# IZBRIS INDEX.HTML APACHE
sudo rm *

Če želite kadar koli znova zagnati Apache, vnesite:

Zdaj gremo skonfigurirat Apache2 za WEBScado tako da v terminalu zažegmo to direktivo:

sudo nano /etc/apache2/apache2.conf

dodajte še kakšen virtualni host po želji npr. pod direktivo /var/www kopirajte pot vaše druge aplikacije:

<Directory /var/www/html/>
	Options Indexes FollowSymLinks
	AllowOverride All
	Require all granted
</Directory>

ZA PREVERIT ČE DELA APACHE ODPRI V BRSKALNIKU URL:

http://IPLocalPI4/

Če ne deluje v terminalu uporabi kodo:

sudo chown -R www-data:www-data /var/www/html/

Ter čiso na koncu kopirajte to direktivo spodaj vse od alineje 228 v apache.conf dodaj localhost ime strežnika in pol ko namestite in popravite vse py datoteke za scada kopirate še v to datoteko solar cybro – PS jaz bi rajši te iste direktive apache.conf od robotina .si kopiral v vHosts se pravi 000-default.conf apache konfiguracija za virtualne hoste:

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
ServerName localhost

## WEBSCADA KO SE NAMESTI SE VKLJUČI SPODNJE DIREKTIVE:
# solar cybro web application static files directory                   

Alias /static/ /home/webscada/app/solar_cybro/static/                     

<directory "/home/webscada/app/solar_cybro/static/">                      
#    Order deny,allow                                                   
    Require all granted                           

</directory>                                                           
# solar cybro web application data directory                           
Alias /data/ /home/webscada/app/solar_cybro/data/                         

<directory "/home/webscada/app/solar_cybro/data/">                        
#    Order deny,allow                                                   
    Require all granted                           

</directory>                                                           

# location of solar cybro wsgi startup file                            

WSGIScriptAlias / /home/webscada/app/solar_cybro/solar_cybro.wsgi         

<directory "/home/webscada/app/solar_cybro/">                             
#    Order deny,allow                                                   

    Require all granted                           

</directory>  

## Te direktive rabijo za scado - shranite datoteko

Lahko pa te iste direktive  zgoraj v apache.conf dodate v vaš virtual hostse pravi za mapo /var/www/html/ doličite pot webscada in izbrišete to iz apache.conf primer 000-defaul.conf to je moj osebni način s to razliko da se naredi en nebulozni host za vaš fiksni ip pred tem hostom spodaj, npr. date server name vaš ip in določite v apache.conf ter 000-default.conf mapo za nebulozni host npr. /var/www/null/ ter ustvarite nek html ali php dokument:

<VirtualHost *:80>

ServerName mojadomena.noip.com

#DocumentRoot /var/www/html

#<Directory /var/www/html/>
#Options Indexes FollowSymLinks MultiViews
#AllowOverride All
#Require all granted
#</Directory>

# solar cybro web application static files directory
Alias /static/ /home/webscada/app/solar_cybro/static/
<directory “/home/webscada/app/solar_cybro/static/”>

Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</directory>


# solar cybro web application data directory
Alias /data/ /home/webscada/app/solar_cybro/data/
<directory “/home/webscada/app/solar_cybro/data/”>

Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</directory>


# location of solar cybro wsgi startup file
WSGIScriptAlias / /home/webscada/app/solar_cybro/solar_cybro.wsgi
<directory “/home/webscada/app/solar_cybro/”>

Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</directory>

ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined

# Enable RewriteEngine
RewriteEngine On
# Recommended: XSS protection
<IfModule mod_headers.c>
Header set X-XSS-Protection “1; mode=block”
Header always append X-Frame-Options SAMEORIGIN
Header set X-Content-Type-Options: “nosniff”
</IfModule>

# Disable HTTP 1.0 Protocol
# RewriteEngine On
RewriteCond %{THE_REQUEST} !HTTP/1.1$
RewriteRule .* – [F]

</VirtualHost>

9) Namestite php 7.4 PI 4-3-2

Zdaj bomo namestili in dali v repository oz. bazo podatkov za nadgradno skriptov php različica 7.4 nekaj direktiv.
V putty oz. terminalu vnesite spodnje direktive:

sudo apt update

sudo apt -y install lsb-release apt-transport-https ca-certificates

sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list

sudo apt update

sudo apt -y install php7.4  libapache2-mod-php7.4

# preverite različico s to komando:
php -v

## urejanje direktiv php
webscada@mojascada:~ $ sudo nano /etc/php/7.4/apache2/php.ini

sudo nano /etc/php/7.4/apache2/php.ini
# vpišite po želji vrednosti se pravi:
max_execution_time = 60
memory_limit = 128M 
post_max_size = 128M
upload_max_filesize = 128M
max_execution_time = 600 
max_input_vars = 3000 
max_input_time = 1000
log_errors = On
error_log = /var/log/php/error.log

Zdaj moramo še ustvarit mapo za napake, v terminalu zažgete spodnji komandi:

sudo mkdir -p /var/log/php

sudo chown www-data /var/log/php

Zdaj module za php 7.4 namestite tako:

sudo apt install php7.4-{common,mysql,cgi,xml,xmlrpc,curl,gd,imagick,cli,dev,imap,mbstring,opcache,soap,zip,intl,bcmath} -y

# ali tako:
sudo apt install -y php7.4-fpm php7.4-mysql php7.4-dom php7.4-simplexml php7.4-ssh2 php7.4-xml php7.4-xmlreader php7.4-curl  php7.4-exif  php7.4-ftp php7.4-gd  php7.4-iconv php7.4-imagick php7.4-json php7.4-mbstring php7.4-posix php7.4-sockets php7.4-tokenizer

Zdaj za WEBMin če želite gledati slike namestite še to:

sudo apt-get install imagemagick php-imagick libmagickcore-dev -y

WEB SCADA potrebuje spodnje module php in serverje Debian 10 / 11:

# sudo apt install apache2 mariadb-server mariadb-client php phpmyadmin libapache2-mod-wsgi acl ssh -y

sudo apt install libapache2-mod-wsgi acl ssh -y

sudo apt install python-django python-pip python-mysqldb -y

# WEB SCADA POTREBUJE TE MOUDLE PHP:
sudo apt install libapache2-mod-php7.4 php7.4-json php7.4-fpm php7.4-cli -y

## Se pravi za php 7.4 lahko namestite tako samo te ki rabite ločite z vejico je krajša komanda:

sudo apt install php7.4-{common,mysql,cgi,xml,fpm,curl,gd,imagick,cli,dev,imap,mbstring,opcache,soap,zip,json} -y

# Za vklopit npr. modul apache rewrite in mysqli:
##sudo phpenmod mysqli
sudo a2enmod rewrite

# in spodnja za ponovno zagnat apache:
sudo systemctl restart apache2

sudo service apache2 restart

10) Namestite SQL server

Namestitev SQL sever zdaj ta najnovejši se imenuje MariaDB
V putty oz. terminalu vnesite spodnje direktive:

sudo apt-get install mariadb-client mariadb-server -y

Skonfiguriraj MariaDB na SSL:

sudo su

cd /etc/mysql

sudo mkdir ssl

cd ssl

4096 ali / or - 2048 je ok

sudo openssl genrsa 2048 > ca-key.pem


Naredimo SSL za Admin MySQL:
sudo openssl req -new -x509 -nodes -days 999000 -key ca-key.pem -out ca-cert.pem
Izpolni SI, itd in za Common Name daj to:
Common Name (e.g. server FQDN or YOUR name) []: MariaDB admin
Naredimo SSL za Server MySQL:
sudo openssl req -newkey rsa:2048 -days 999000 -nodes -keyout server-key.pem -out server-req.pem
Izpolni SI, itd in za Common Name daj to:
Common Name (e.g. server FQDN or YOUR name) []: MariaDB server
Naredimo SSL za Server MySQL:
sudo openssl req -newkey rsa:2048 -days 999000 -nodes -keyout client-key.pem -out client-req.pem
Izpolni SI, itd in za Common Name daj to: Common Name (e.g. server FQDN or YOUR name) []: MariaDB client
Zdaj preveri če so vsi certifikati ok:
sudo openssl rsa -in server-key.pem -out server-key.pem
sudo openssl x509 -req -in server-req.pem -days 999000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 -out server-cert.pem
sudo openssl rsa -in client-key.pem -out client-key.pem
sudo openssl x509 -req -in client-req.pem -days 999000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 -out client-cert.pem
openssl verify -CAfile ca-cert.pem server-cert.pem client-cert.pem

Aktiviraj v SQL SSL: sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
## Dodaj v sekciji [mysqld] spodnje direktive: ## mariadb will use TLSv1.0 or better. ##
ssl = on
ssl-ca=/etc/mysql/ssl/ca-cert.pem
ssl-cert=/etc/mysql/ssl/server-cert.pem
ssl-key=/etc/mysql/ssl/server-key.pem

Dodeli pooblastila:
sudo chown -Rv mysql:root /etc/mysql/ssl/
sudo systemctl restart mysql

ZDAJ ŠE V MYSQL CLIENTS DODAJ V SEKCIJI [mysql] SPODNJE DIREKTIVE:

sudo nano /etc/mysql/mariadb.conf.d/50-mysql-clients.cnf

## MySQL Client Configuration ##
ssl-ca=/etc/mysql/ssl/ca-cert.pem
ssl-cert=/etc/mysql/ssl/client-cert.pem
ssl-key=/etc/mysql/ssl/client-key.pem

zDAJ KOPIRAJTE VSAKEMU KLIJENTU VAŠ SSL CERTIFIKAT OZ. VAŠIM RAČUNOM:

{admin@mojserver}: rsync /etc/mysql/ssl/ca-cert.pem /etc/mysql/ssl/client-cert.pem /etc/mysql/ssl/client-key.pem \
admin@localhost:/etc/mysql/ssl

Vpiši svojo kodo in tako naredi za vsak račun npr.

rsync /etc/mysql/ssl/ca-cert.pem /etc/mysql/ssl/client-cert.pem /etc/mysql/ssl/client-key.pem \
webscada@localhost:/etc/mysql/ssl

pojdi preverit če vse dela sudo su in mariadb:

mariadb

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 30
Server version: 10.5.15-MariaDB-0+deb11u1 Raspbian 11

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SHOW VARIABLES LIKE '%ssl%';
+---------------------+--------------------------------+
| Variable_name | Value |
+---------------------+--------------------------------+
| have_openssl | YES |
| have_ssl | YES |
| ssl_ca | /etc/mysql/ssl/ca-cert.pem |
| ssl_capath | |
| ssl_cert | /etc/mysql/ssl/server-cert.pem |
| ssl_cipher | |
| ssl_crl | |
| ssl_crlpath | |
| ssl_key | /etc/mysql/ssl/server-key.pem |
| version_ssl_library | OpenSSL 1.1.1n 15 Mar 2022 |
+---------------------+--------------------------------+
10 rows in set (0.006 sec)

MariaDB [(none)]> status;
--------------
mariadb Ver 15.1 Distrib 10.5.15-MariaDB, for debian-linux-gnueabihf (armv8l) using EditLine wrapper

Connection id: 30
Current database:
Current user: root@localhost
SSL: Cipher in use is TLS_AES_256_GCM_SHA384
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server: MariaDB
Server version: 10.5.15-MariaDB-0+deb11u1 Raspbian 11
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /run/mysqld/mysqld.sock
Uptime: 3 min 43 sec

Threads: 1 Questions: 60 Slow queries: 0 Opens: 32 Open tables: 25 Queries per second avg: 0.269
--------------

MariaDB [(none)]> quit
Bye

11) Namestite phpmyadmin

Namestitev phpmyadmin, bomo potrebovali ta program za lažji uvoz SQL baz podatkov ali pa redne varnostne kopije SQL baze podatkov ma vse to vam bo delal WEBMin!!! PhpMyAdmin potrebuje webscada pridemo do tega še….
V putty oz. terminalu vnesite spodnje direktive:

sudo apt-get install phpmyadmin -y

Zdaj vas vpraša ko se namešča program za uporabniško ime phpmyadmin da določite eno kodo, dajte npr. nekaj hard oz. težjo kodo vse to si zapišite!

Npr. pri namestitvi phpmyadmin vas vpraša za kodo uporabnik:
phpmyadmin

npr. koda dajte kaj tazga, to velja vedno tudi za sql bazo ali pa še posebej npr. za uporabnika webscada naj bo kompleksna koda!!!

Koda za phpmyadmin: 4R4pESMaZbkcvN79kR3K4BeK
Ni pa nujno po želji določite eno kodo!!!

Zdaj se lahko prijavimo v phpmyadmin tako, da odpremo v brskalniku:

http://192.168.1.82/phpmyadmin/

### se pravi vaš ip raspberry!!!

Če so neki hrošči za popravit poglejte npr. google.com in napišite oz. kopirajte uno napako št. tukaj vam pokažem kako odpravit en hrošč, vendar boste ni pa potrebno mogli še za neke fonte oz pisavo popravit hrošče oz. bugs jaz pravim, boste mogli DEBUGIZIRAT oz. RAZHROŠČIT SKRIŠTE TAKO: NE RABI VEČ POPRAVLJAT V RASBIAN LINX 11 !!!!! SE UPORABLJA PO DEFAULTU POPRAVLJENA VERZIJA 5.0.4

sudo nano +551 /usr/share/phpmyadmin/libraries/plugin_interface.lib.php

Popravite alinejo ki se glasi tako:

if ($options != null && count($options) > 0) {

spremenite tako, da izgleda tako:

if ($options != null && count((array)$options) > 0) {

Pol so še hrošči kot sem reku za neke fonte oz. pisave, ma ni to pomembo, glejte github.com spletno mesto so vsi popravki hroščev za phpmyadmin, ni težko mislim če se pravilno spomnim da je za popravit v mapi, /usr/share/php/tcpdf/tcpdf.php v alineji 1963:

sudo nano +1963 /usr/share/php/tcpdf/tcpdf.php
TCPDF_FONTS::utf8Bidi(array(''), '', false, $this->isunicode, $this->CurrentFont);

popravite tako oz. debugizirate odpravite hrošča z:

TCPDF_FONTS::utf8Bidi(array(), '', false, $this->isunicode, $this->CurrentFont);

Posodobite phpmyadmin na npr. 5.0.4

cd /usr/share/phpmyadmin/
sudo su

wget https://perc.ddns.net/downloads/phpmyadmin504.zip

unzip phpmyadmin504.zip
rm phpmyadmin504.zip

sudo cp /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php

sudo nano /usr/share/phpmyadmin/config.inc.php

$cfg['blowfish_secret'] = 'VPIŠI-SVOJO-KODO-ZAKODIRAT-COOKY'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
/* User used to manipulate with storage */
// $cfg['Servers'][$i]['controlhost'] = '';
// $cfg['Servers'][$i]['controlport'] = '';
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = 'MOJSERVER123456789';
/* Storage database and tables */
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
$cfg['Servers'][$i]['relation'] = 'pma__relation';
$cfg['Servers'][$i]['table_info'] = 'pma__table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma__column_info';
$cfg['Servers'][$i]['history'] = 'pma__history';
$cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
$cfg['Servers'][$i]['tracking'] = 'pma__tracking';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
$cfg['Servers'][$i]['recent'] = 'pma__recent';
$cfg['Servers'][$i]['favorite'] = 'pma__favorite';
$cfg['Servers'][$i]['users'] = 'pma__users';
$cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
$cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
$cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';
$cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';
$cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings';
$cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';

$cfg['TempDir'] = '/var/lib/phpmyadmin/tmp';
$cfg['SaveDir'] = '/var/lib/phpmyadmin/doc';
$cfg['UploadDir'] = '/var/lib/phpmyadmin/ddl';

Shrani in ustvari mape ter jim dodeli dkupino in uporabnika:

sudo mkdir /var/lib/phpmyadmin/tmp
sudo mkdir /var/lib/phpmyadmin/doc
sudo mkdir /var/lib/phpmyadmin/ddl

sudo chown -R www-data:www-data /var/lib/phpmyadmin/tmp
sudo chown -R www-data:www-data /var/lib/phpmyadmin/doc
sudo chown -R www-data:www-data /var/lib/phpmyadmin/ddl

 

Instaliraj password generator da maš pol kode vedno za karkoli tako:
sudo apt install pwgen
Kodo generiraš npr. eno kodo od 32 mest tako:
pwgen -s 32 1

 

#phpmyadmin upgrade – update new version: Gremo dalje ko si uno gor naredu zdaj obvezno tako:
sudo mariadb < /usr/share/phpmyadmin/sql/create_tables.sql
sudo mariadb

GRANT SELECT, INSERT, UPDATE, DELETE ON pma_db.* TO ‘pma’@’localhost’ IDENTIFIED BY ‘MOJSERVER123456789’;
GRANT SELECT, INSERT, UPDATE, DELETE ON phpmyadmin.* TO ‘pma’@’localhost’ IDENTIFIED BY ‘MOJSERVER123456789’;
GRANT ALL PRIVILEGES ON *.* TO ‘phpmyadmin’@’localhost’ WITH GRANT OPTION;
FLUSH PRIVILEGES;

GRANT ALL PRIVILEGES ON *.* TO ‘admin’@’localhost’ IDENTIFIED BY ‘SudoKodaAdministratorjaSQL’ WITH GRANT OPTION;
FLUSH PRIVILEGES;

prijavite se v phpmyadmin http://serverip/phpmyadmin/

admin

SudoKodaAdministratorjaSQL

12) Namestite WEBSCADA CybroTech Kontrolerji

Recimo da ste ustvarli xy uporabnika lahko direktno poberete iz mojega mesta app in samo menjate poti serverja v nastavitvah za vašega uporabnika scada:

cd /home/webscada/
wget https://perc.ddns.net/downloads/app.zip
unzip app.zip
sudo setfacl -m u:www-data:--x /home/webscada/app
sudo setfacl -R -m u:www-data:--- /home/webscada/app/*
sudo setfacl -R -m u:www-data:rwx /home/webscada/app
sudo setfacl -R -m d:u:www-data:rwx /home/webscada/app
sudo chmod g+s /home/webscada/app
sudo setfacl -R -m d:u:webscada:rwx /home/webscada/app
sudo chmod 755 /home/webscada/app/scgi_server/src/cybro_com_server.py
sudo chmod 755 /home/webscada/app/scgi_server/src/cybro_scgi_server.py
sudo chmod 755 /home/webscada/app/scgi_server/src/run_scgi_server.py
app/scgi_server/src/cybro_scgi_server.py start

 

Prvo si prenesemo WEBScado na naš račun oz. uporabnika webscada:

wget http://www.cybrotech.com/wp-content/uploads/2019/04/CyBroWebScada-v1.1.10-v2.3.0.zip

Zdaj jo odpakirajte z direktivo:

unzip CyBroWebScada-v1.1.10-v2.3.0.zip

Kot sem že napisal scada rabi sledeče module:

# WEB Scada rabi spodnje serverje in apps Debian 10 Raspbian 10 Ubuntu14-18:
sudo apt install apache2 mariadb-server mariadb-client php7.4 phpmyadmin libapache2-mod-wsgi acl ssh -y 

# POZOR python django apps (Scada novejši django apps so različico 3.1 NE deluje, za CybroTech WEB Scado.. to rezličico uporabite sudo pip install django==1.3

sudo apt install python-django python-pip python-mysqldb -y

sudo apt install libapache2-mod-php7.4 php7.4-json php7.4-fpm php7.4-cli libapache2-mod-wsgi acl ssh -y

# Potrebna programska oprema za WEB Scada Ubuntu:
    $ sudo apt-get install apache2 mysql-server php5 phpmyadmin libapache2-mod-wsgi acl ssh

    $ sudo apt-get install python-pip python-mysqldb
    $ sudo pip install django==1.3
    $ sudo pip install pytz
    $ sudo apt-get install python-dev python-setuptools
    $ sudo apt-get install libjpeg-dev zlib1g-dev
    $ sudo pip install pillow
    $ sudo apt-get install apache2 mariadb-server php phpmyadmin libapache2-mod-wsgi acl ssh
    $ sudo apt-get install python-django python-pip python-mysqldb

Zdaj gremo še v avtomatični zagon programov in kopiramo spodnje direktive:

sudo nano /etc/rc.local

# KOPIRAJTE TO TAKO:
# rc.local
sudo -u webscada /home/webscada/app/scgi_server/src/run_scgi_server.py
# sudo noip2
# sudo ufw enable
#
# This script is executed at the end of each multiuser runlevel.

IN LAHKOŠE CRON JOBS OZ. CRON TABLES DATE TO DIREKTIVO TAKO:

crontab -e

# KOPIRAJTE NA KONCU DA SE SAMODEJNO ZAŽENE WSCGI STREŽNIK:

*/1 * * * * /home/webscada/app/scgi_server/src/run_scgi_server.py &>/dev/null

*/10 * * * * /home/webscada/app/solar_cybro/project/run_create_reports.py &>/dev/null

*/2 * * * * /home/webscada/app/solar_cybro/project/run_send_reports.py &>/dev/null


# PONOVNI ZAGON APACHE TAKO:
sudo service apache2 restart

# ali
sudo apachectl -k restart

Zdaj zaženemo se ti dve komandi v terminalu npr. putty:

cd /home/webscada

setfacl -m u:www-data:--x /home/webscada
setfacl -R -m u:www-data:--- /home/webscada/app/*
setfacl -R -m u:www-data:rwx /home/webscada/app
setfacl -R -m d:u:www-data:rwx /home/webscada/app
chmod g+s /home/webscada/app
setfacl -R -m d:u:webscada:rwx /home/webscada/app

sudo setfacl -m u:www-data:--x $HOME && sudo setfacl -R -m u:www-data:--- $HOME/app/* && sudo setfacl -R -m u:www-data:rwx $HOME/app && sudo setfacl -R -m d:u:www-data:rwx $HOME/app && sudo chmod g+s $HOME/app && sudo setfacl -R -m d:u:webscada:rwx $HOME/app

sudo chmod 755 app/scgi_server/src/cybro_com_server.py && sudo chmod 755 app/scgi_server/src/cybro_scgi_server.py && sudo chmod 755 app/scgi_server/src/run_scgi_server.py

# Daljša varianta kopirajte vse skupaj v terminal:
sudo setfacl -m u:www-data:--x $HOME
sudo setfacl -R -m u:www-data:--- $HOME/app/*
sudo setfacl -R -m u:www-data:rwx $HOME/app
sudo setfacl -R -m d:u:www-data:rwx $HOME/app
sudo chmod g+s $HOME/app
sudo setfacl -R -m d:u:webscada:rwx $HOME/app

# Spremenite pooblastila datotekam:
sudo chmod 755 app/scgi_server/src/cybro_com_server.py
sudo chmod 755 app/scgi_server/src/cybro_scgi_server.py
sudo chmod 755 app/scgi_server/src/run_scgi_server.py

sudo service apache2 restart

# Lahko krajša varianta za pooblastila:
sudo setfacl -m u:www-data:--x $HOME && sudo setfacl -R -m u:www-data:--- $HOME/app/* && sudo setfacl -R -m u:www-data:rwx $HOME/app && sudo setfacl -R -m d:u:www-data:rwx $HOME/app && sudo chmod g+s $HOME/app && sudo setfacl -R -m d:u:webscada:rwx $HOME/app

sudo chmod 755 app/scgi_server/src/cybro_com_server.py && sudo chmod 755 app/scgi_server/src/cybro_scgi_server.py && sudo chmod 755 app/scgi_server/src/run_scgi_server.py

Zdaj npr. če naredite takšno bazo podatkov za SQL kot bom jaz in seveda ste prijavljeni v terminal z uporabnikom webscada:

sudo nano  /home/webscada/app/solar_cybro/project/settings_local.py

Datoteka izgleda tako, jaz sem ustvaril SQL bazo podatkov za scado tako da je baza SQL pod imenom bazasolar in uporabnik webscada – vi lahko to po želji kakor vam paše to bomo generirali bazo in uporabnika v naslednjem poglavju, če boste dodelili drugo to tudi primerno spremenite:

# -*- coding: utf-8 -*-

import version

ADMINS = (
    ('Cybrotech', 'info@cybrotech.hr'),
)

DATABASE_ENGINE = 'mysql'       # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'scada'         # Or path to database file if using sqlite3.
DATABASE_USER = 'scada'          # Not used with sqlite3.
DATABASE_PASSWORD = 'p90k7VOEaLppRx2a'     # Not used with sqlite3.
DATABASE_HOST = 'localhost'              # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '3306'              # Set to empty string for default. Not used with sqlite3.

SMTP_HOST = 'smtp.dummy.com'
SMTP_HOST_USER = 'solar_noreply'
SMTP_HOST_PASSWORD = ''
SMTP_PORT = 25
SMTP_USE_TLS = False
DEFAULT_FROM_EMAIL = "noreply@..." # from address for server error emails
SERVER_EMAIL = "noreply@..."    # used as the from address for django.core.mail.mail_admins() and django.core.mail.mail_managers()

TIME_ZONE = 'Europe/Zagreb'
SECRET_KEY = "$$|Y6_0f]6$1&^8Wv4673;J%JR-b%ln@iV6?AhI.5,t?>`kS"
REPORT_FROM_EMAIL = "noreply..."
REPORT_EMAIL_SUBJECT = 'CyBroWebScada: report'
SCGI_URL = "http://localhost/scgi/?"
SCGI_PORT = 4000
DATA_DIRECTORY = "/home/webscada/app/solar_cybro/data/"
CYBRO_SCGI_SERVER_DIRECTORY = "/home/webscada/app/scgi_server/"
SITE_URL = "https://perc.ddns.net/admin/webscada/"
PAGE_CACHE_VALIDITY = 3600 # seconds
ADMIN_MEDIA_PREFIX = '/media/admin/'
TIMEPLOT_INTERPOLATION = 4      # cumulative timeplot, defines how many bars (left and right) to take into account

STATIC_SETTINGS = {
    "site_name": "Solar CyBro",
    "contact_email": "mailto:info@cybrotech.hr?subject=SolarServer",
    "head_caption": "solar plant supervisory system",
    "footer_text": 'cybro web scada v%s, copyright &copy; 2010-2013. <a href="http://www.cybrotech.co.uk/">Cybrotech Ltd.</a>' % version.WebSoftwareVersion,
    "google_webmaster_tools_code": "",
    "shortcut_icon": "/static/misc/favicon.ico",
}

Zdaj npr. če naredite takšno bazo podatkov za SQL kot bom jaz in seveda ste prijavljeni v terminal z uporabnikom webscada:

sudo nano  /home/webscada/app/scgi_server/src/sys_config.py

Popravi v svoje podatke SQL!!!

# database settings
DatabaseEngine = "mysql"
DatabaseHost = "localhost"
DatabaseName = "scada"
DatabaseUser = "scada"
DatabasePassword = "p90k7VOEaLppRx2a"
DatabaseDataLoggerSamplesTable = "measurements"
DatabaseDataLoggerAlarmsTable = "alarms"
DatabaseDataRelayDataTable = "relays"
DatabaseDataControllersTable = "controllers"

Se pravi vi spremenite na bazi vaše podatke za SQL baza in uporabnik, katerega bomo zdaj ustvarli, mojem primeru za pi4 test kot sm rekel je:

DATABASE_NAME = 'scada'
DATABASE_USER = 'scada'
DATABASE_PASSWORD = 'p90k7VOEaLppRx2a' 

13) Namestimo oz. Generiramo za WEBScado SQL bazo in uporabnika

Zdaj prvo zaženete spodnjo komando in odgovorite tako prvi odgovor je Y oz. yes (DA) in vsi ostali odgovori so N oz. no (NE):

sudo mysql_secure_installation

Zdaj se prijavite v SQL v.10.xx oz. Maria DB tako da vpišete vašo kodo za uporabnika webscada ali če boste namestili na drugega uporabnika pol vse direktive kjer je pri meni moj primer webscada spremenite z uporabnikom, ki ste ga generirali za WEB Scado:

sudo mysql --user=root --password=mojawebscada1234koda

## Se pravi kot je moja koda za test PI4 se pravi mojawebscada1234koda vi to samo zamenjate z vašo kdo, ki ste jo dali za uporabnika webscada oz. tistega uporabnika kjer bo scada nameščena karkoli!!!

V mariaDB kopirajte spodnje direktive vse in kar z desnim miškinim kazalcem kliknite v terminal, ne pozabit spremenit vašo kodo lahko tudi ime baze in uporabnika po želji:

Za mariaDb ustvarite samo bazo in uporabnka ker dodelite vse privilegije pol omejite v phpmyadmin.

CREATE DATABASE scada;
CREATE USER 'scada'@'localhost' IDENTIFIED BY 'p90k7VOEaLppRx2a';
GRANT ALL PRIVILEGES ON scada.* to 'scada'@'localhost';
FLUSH PRIVILEGES;

exit

in zdaj v račun webscada iz terminala naložite app  že pripravljeno vse:

cd /home/webscada/

wget https://perc.ddns.net/downloads/app.zip

unzip app.zip
rm app.zip

setfacl -m u:www-data:--x /home/webscada/app
setfacl -R -m u:www-data:--- /home/webscada/app/*
setfacl -R -m u:www-data:rwx /home/webscada/app
setfacl -R -m d:u:www-data:rwx /home/webscada/app
chmod g+s /home/webscada/app
setfacl -R -m d:u:webscada:rwx /home/webscada/app
chmod 755 /home/webscada/app/scgi_server/src/cybro_com_server.py
chmod 755 /home/webscada/app/scgi_server/src/cybro_scgi_server.py
chmod 755 /home/webscada/app/scgi_server/src/run_scgi_server.py

sudo mkdir /home/webscada/app/solar_cybro/data/cache
sudo mkdir /home/webscada/app/solar_cybro/data/media
sudo mkdir /home/webscada/app/solar_cybro/data/scripts
sudo mkdir /home/webscada/app/solar_cybro/data/analize

 

sudo nano /etc/rc.local

sudo -u webscada /home/webscada/app/scgi_server/src/run_scgi_server.py

cd /home/webscada/

app/scgi_server/src/cybro_scgi_server.py start

 


webscada@mojascada:~ $ app/scgi_server/src/cybro_scgi_server.py status

CybroScgiServer v2.3.3 (c) 2010-2014 Cybrotech Ltd. All rights reserved.
————————————————————————
CybroScgiServer is running.

sys.scgi_port_status: active
sys.scgi_request_count: 11550
sys.scgi_request_pending: 0
sys.server_version: 2.3.3
sys.server_uptime: 1:48:04
sys.cache_valid: 5
sys.cache_request: 2
sys.push_port_status: active
sys.push_count: 109
sys.push_list_count: 1
sys.push_ack_errors: 1
sys.push_list:
push message nad ip address:port status program alc program downloaded response
——————————————————————————————————-
2022-05-14 23:15:02 12133 89.212.137.96:61361 run ok ok 2022-05-14 21:48:52 63
——————————————————————————————————-

sys.udp_rx_count: 10636
sys.udp_tx_count: 10658
sys.abus_list:
nad abus total abus error last error at code bandwidth
——————————————————————————————————-
12133 10658 21 2022-05-14 20:57:44 tout 18.63%
——————————————————————————————————-

sys.datalogger_status: active
sys.datalogger_list:
type tags tasks trigger count last request at tags ok tags err status duration
——————————————————————————————————-
sample 39 4 317 2022-05-14 21:15:00 28 8 ok 75ms
alarm 9 1 108 2022-05-14 21:15:00 6 3 ok 53ms
event 27 3 6226 2022-05-14 21:15:07 6 6 ok 81ms
——————————————————————————————————-

webscada@mojascada:~ $

 

sudo /home/webscada/app/scgi_server/src/cybro_scgi_server.py restart
sudo /home/webscada/app/scgi_server/src/cybro_scgi_server.py restart
sudo /home/webscada/app/scgi_server/src/cybro_scgi_server.py stop
sudo /home/webscada/app/scgi_server/src/cybro_scgi_server.py start
sudo /home/webscada/app/scgi_server/src/cybro_scgi_server.py status

Goran Kociančič WEB Scada 2022 Raspbian 10 Linux Deluje vse razen Templates boste mogli posebej generirat v phpmyadmin tabelo, drugo vse dela – trenutna kopija ki jo poberete iz robotinal.si delajo templates pero ne delajo kontrolerji se jih ne da registrirat napaka!!!! Poberite to verzijo Testirana deluje na Ubuntu14-18-20 in Debian 9 10 11 in Raspbian 10 in 11 / 32 ali 64 bit testirano deluje vse kot mora!!!
Za generirat templates če ne popravite v python skripta da dela za mariadb mysql pol lahko enostavno tako uredite problem!

Prijevite se v phpmyadmin odprite scada bazo in poiščite templates kliknite na njega in zgoraj jeziček Vstavi dodaj po vrsi id 1, 2, za vsak template določiš npr ime kuhinja, centralna, sončna,…… Lahko pa razhroščite tudi tako da v python popravite ker Delbian 10 11 po defaultu uporablja MYSQL10 lahko si tudi namestite MYSQL8 in vam bo delalo vse!!!


 

CREATE DATABASE `bazasolar` DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;

# Ali krajše samo:
create database bazasolar;

# Za menjat kodo SQL root - ni potrebno!!!!
SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('mojawebscada1234koda');

SET PASSWORD FOR 'root'@'::1' = PASSWORD('mojawebscada1234koda');

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('mojawebscada1234koda');


# Ustvarit uporabnika SQL:
create user 'webscada'@'localhost' identified by 'MojaKodaSQL12345KarkoliWEBSCADA' WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;

# Sprosti vse privilegije za bazo in uporabnika:
GRANT ALL PRIVILEGES ON `bazasolar` . * TO 'webscada'@'localhost';

# Ali krajše sprosti privilegije:
grant all privileges on bazasolar.* to 'webscada'@'localhost';

# Za konec še to in izhod....
flush privileges;

exit;

V phpmyadmin uvozite osnovne dve baze, to lahko tudi storite preko terminala:

Zdaj če ste naredili po moje bazo in uporabnika gremo v phpmyadmin http://192.168.1.85/phpmyadmin/ in se prijavite tako z vašimi pristopnimi podatki za SQL uporabnika se pravi po moji varianti:

Uporabnik: webscada

Geslo: MojaKodaSQL12345KarkoliWEBSCADA

Zdaj pridemo v phpmyadmin in uvozimo bazo podatkov SQL od solar oz. ko ste odpakirali to datoteko zip “CyBroWebScada-v1.1.10-v2.3.0.zip” na vaš računalnik je v mapi DOC SQL baza podatkov od robotine katero moramo uvozit se pravi datoteke:

solar.sql

time_zone.sql

# Dodatne baza sql robotina.si

db_dump_v110.sql db_upgrade_v110_to_v113.sql db_upgrade_v113_to_v115.sql db_upgrade_v114_to_v115.sql

Uvozimo v phpmyadmin v meniju uvozi ter kliknite izberi datoteko ter eno po eno izberete in kliknete spodnji gumb “Izvedi

http://www.cybrotech.com/software-category/tools/

POZOR! DEBIAN 11 IN UBUNTU 20 NIMAJO VEČ TEH STARIH REPO! VEČINA MODULOV BOSTE MOGLI NAMESTIT IZ SOURCE – Apache WSCGI in MYSQL-python !!!

ZA PONOVNO ZAGNAT WSCGI SERVER UPORABITE V TERMINALU:

Zaženi na zadnje install django apps:

Software install - CybroTech WEB Scada:
    $ sudo apt-get install apache2 mariadb-server mariadb-client php7.4 phpmyadmin libapache2-mod-wsgi acl ssh
    $ sudo apt-get install python-django python-pip python-mysqldb
    $ sudo pip install pytz

## na kondu Django v.13 obvezno ne novejših....

sudo apt install python-django python-pip python-mysqldb -y

sudo apt install libapache2-mod-php php-json php-fpm php-cli -y

sudo pip install django==1.3

sudo app/scgi_server/src/cybro_scgi_server.py restart

sudo app/scgi_server/src/cybro_scgi_server.py status

sudo app/scgi_server/src/cybro_scgi_server.py stop

sudo app/scgi_server/src/cybro_scgi_server.py start

IN ZDAJ IMATE NAMEŠČENO SPLETNO APLIKACIJO WEB SCADA, OBIŠČETE NPR. VAŠ INTERNI IP RASPBERRY PI IN MOGLA BI SE VAM ODPRETI STRAN:

Prijavite se z Uporabnik: admin in Geslo: admin

POSREDUJTE PORTE IN ČE ŽELITE ZA SCADO SSL NAMESTITE CERTBOT FREE SSL

Za enkrat iz moje strani to bo vse, zaščitite primerno vaš serverček, npr. požarni zid ufw oz. nekomplicirani požarni zid od Ubuntu, deluje tudi za Raspbian Linux vendar ga odsvetujem za WEB Scado, uporabite direktive iptables katere sem vam predstavil zgoraj ne pozabit pol oddobrit porte 4000 in 8442 ter web porte 80 ter za ssl 443, jaz priporočam, še uporabo Fail2Ban spletne aplikacije, npr. za prijavni modul fail2ban zaščita priave za WEB Scada v mapi /etc/fail2ban/filter.d/ ustvarite nov filter tako da:

sudo nano /etc/fail2ban/filter.d/webscada.conf

Kopirajte vse to v datoteko in shranite (# Prva in druga postavka je eno te isto in trejta ter četrta enako, v bistvu sem vam vpisal ali eno ali drugon ne igra vloge tisti, ki bodo falili prijavo jih zaklene!!!):

[Definition]

failregex = ^<HOST>.* "POST /accounts/login/.*

ignoreregex =

Kopirate Zgornje Direktive shranite in v fail2ban jail.local aktivirate modul f2b za zaščito prijeve webscada tako, da na koncu datateke jail.local vpišete direktive za vklop filtera tako:

[webscada]
enabled = true
port 	= http,https
filter 	= webscada
logpath = %(apache_access_log)s
bantime  = 24h
maxretry = 6
banaction = %(banaction_allports)s

Te direktive za zaščito prijavnega mesa webscada pomenijo tako, se pravi kdorkoli bo falil prijavo 6 krat ga požarni zid zablokira za 24h to si sami parametrirajte po želji!!!

Zdaj kako se upravlja CMS WEB Scada pa preberite dokumentacijo, jaz vseh sintaks nimam, in na žalost mi robotina.si oz. cybrotech.com ni poslal dokumentacije, ki sem jo zahteval da bi vam olajšal delo, obrnite se na njihove servisne strani!

14) WEBMin – webmin.com – Jaz vam svetujem namestitve tega programa za lažje delo z strežnikom rasbian

Kaj je WEBmin ne bom razlagal to si poglejte na njihovi strani https://webmin.com/ PRAKTIČNO VAM BO OLAJŠALO DELO Z VAŠIM RASPBIAN SERVERJEM OZ. STREŽNIKOM, NE BOSTE POTREBOVALI VEČ TERMINALA OZ. PUTTY SAMO ŠE ZA SSL CERTIFIKATE IN GLAVNE NASTAVITVE BOSTE RABILI TERMINAL DRUGAČE VSE LAHKO NASTAVLJATE V WEBMIN ČISTO ENOSTAVNO – NE POTREBUJETE FTP SERVERJA, KER BOSTE VSE DELALI PREKO WEBMIN IN FILE MANAGER, BOLJ POENOSTAVLJENO, KOT BI IMELI WINDOWS SERVER, S TO RAZLIKO DA SE LINUX NIČ SAM NE NASTAVI!!!!

GREMO NAMESTIT WEBMIN TAKO DA V TERMINALU ZAŽGETE TO KOMANDO OZ. DIREKTIVO:

sudo nano /etc/apt/sources.list

Čiso na koncu kopirajte to direktivo:

deb https://download.webmin.com/download/repository sarge contrib

Da, Sarge je stara različica Debiana, vendar se to skladišče redno posodablja
Zdaj morate namestiti ključ GPG, ki ustreza temu repozitoriju oz. skladišču zažgite v terminalu spodnje komandi:

sudo wget http://www.webmin.com/jcameron-key.asc

sudo apt-key add jcameron-key.asc

Zdaj pa še za konec namestimo webmin tako da v terminalu kopiramo te komande oz. direktive sorry sm primorec ne uporabljam dvojine:

sudo apt update

sudo apt install webmin -y

KO STE NAMESTILI WEBMIN GA ŠTARTATE OZ. SE PRIJAVITE NA NJEGA TAKO DA V VAŠ BRSKALNIK (Chrome, Opera, Internet Explorer, Mozzila,…..) VPIŠETE:

https://ipraspberry:10000/

npr. https://192.168.1.82:10000
Potrdite samoregistrirani SSL od WEBMin in se prijavite npr. z uporabnikom WEBSCADA in GESLOM

Zdaj namestite še ta program za nadgradno npr. tem webmin in ostalo:

sudo apt-get install git -y

Pol če boste implementirali za vaš server npr. SSL Certifikat CertBot pa boste v webmin meni “Webmin Configuration” namestili še modul CertBot tako, da kliknete na ikono Webmin Modules in v polje “From HTTP or FTP URL” boste vpisali oz. kopirali spodnjo povezavo URL ter kliknili Install Module

http://cdn.acugis.com/certbot-webmin-module/certbot.wbm.gz

Zdaj vse namestitve modulov, lahko namestite preko webmin z klikom na željeni modul npr. apache, sql, ftp (ne rabi),….. Ampak jaz vam bom tu dalje vse pokazal za terminal namestitev dodatnih modulov!

15) Namestiom UFW nekomplicirani požarni zid za linux – ODSVETUJEM ZA UPORABNIKE WEBSCADA:

Namestite ufw zaženi v terminalu: (ZA RASPBERRY PI WEB SCADA SMO ŽE VSE ZAŠČITILI Z IPTABLES LINUX POŽARNIM ZIDOM – NE RABITE, ZA DOMAČE UPORABNIKE ZAPRTA OMREŽJA LAHKO BREZ PROBLEMOV NAMESTITE ŠE UFW PO ŽELJI – UFW to je od Ubuntu Linux “Nekomplicirani Požarni Zid” vendar ga vam jaz osebno odsvetujem, še posebej če imate večje število kontrolerjev po Sloveniji ali tujini npr. za nadzor poslovnih prostorov, vikend hiš, stanovanj, itd…)

Ta požarni zid vam odsvetujem za WEB Scado, ker vam bo blokiral kontrolerje oz. vam ne bo dodelil UDP porta preko porta 8442 ne gelde, če le tega posredujete v splet!!! Uporabite iptables z direktivami, ki sem vam jih pripravil!!!

###Glavna direktiva iptables odpri porte preko iptables tako:
 sudo iptables -A INPUT -p tcp -m tcp -m multiport -j ACCEPT --dports 22,80,443,4000,8442
 sudo iptables -A INPUT -p udp -m udp --dport 1024:65535 --sport 8442 -j ACCEPT  

## ali posamezni port primer pred vsakim -A dodate sudo iptables:
-A INPUT -p tcp -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 25 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 465 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 587 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 143 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 993 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 110 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 995 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 4000 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 8442 -j ACCEPT


Lastne nastavitve primer vBox WEB Scada Debian 10+11 / 32 ter 64bit Shema: Router IP 192.168.1.1 Server IP 192.168.1.100 Main Server Server IP 192.168.1.111 Multimedia Server IP 192.168.1.123 RPI-10 Server IP 192.168.1.222 WindowsNT 
iptables custom perc settings - ipv4 + ipv6
OBVEZNO IPTABLES SM PRIPRAVU TAKO GLEJ DIREKTIVE, DA ČE SI PRIJAVLJEN V KARKOLI SQL, SCADA ITD… SI ODOBREN, POL BLOKADA NA SSH, ČIM FALIŠ ITD… sudo apt update && sudo apt upgrade && sudo apt install iptables -y sudo reboot sudo iptables -L sudo ip6tables -L sudo nano /tmp/v4 *mangle :PREROUTING ACCEPT [0:0] :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] :POSTROUTING ACCEPT [0:0] COMMIT *nat :PREROUTING ACCEPT [0:0] :INPUT ACCEPT [0:0] :OUTPUT ACCEPT [0:0] :POSTROUTING ACCEPT [0:0] COMMIT *raw :PREROUTING ACCEPT [0:0] :OUTPUT ACCEPT [0:0] COMMIT *filter :INPUT DROP [0:0] :FORWARD DROP [0:0] :OUTPUT DROP [0:0] -A INPUT -i lo -j ACCEPT -A INPUT ! -i lo -d 127.0.0.0/8 -j REJECT -A INPUT -d 127.0.0.0/8 -j REJECT –reject-with icmp-port-unreachable -A INPUT -m state –state RELATED,ESTABLISHED -j ACCEPT -A INPUT -m conntrack –ctstate RELATED,ESTABLISHED -j ACCEPT -A INPUT ! -i eth0 -j ACCEPT -A INPUT -p tcp -m tcp –tcp-flags ACK ACK -j ACCEPT -A INPUT -p tcp -m conntrack –ctstate NEW,ESTABLISHED -m tcp –dport 80 -j ACCEPT -A INPUT -p tcp -m conntrack –ctstate NEW,ESTABLISHED -m tcp –dport 443 -j ACCEPT -A INPUT -p tcp -m conntrack –ctstate NEW,ESTABLISHED -m tcp –dport 21 -j ACCEPT -A INPUT -p tcp -m conntrack –ctstate NEW,ESTABLISHED -m tcp –dport 25 -j ACCEPT -A INPUT -p tcp -m conntrack –ctstate NEW,ESTABLISHED -m tcp –dport 143 -j ACCEPT -A INPUT -p tcp -m conntrack –ctstate NEW,ESTABLISHED -m tcp –dport 993 -j ACCEPT -A INPUT -p tcp -m conntrack –ctstate NEW,ESTABLISHED -m tcp –dport 110 -j ACCEPT -A INPUT -p tcp -m conntrack –ctstate NEW,ESTABLISHED -m tcp –dport 995 -j ACCEPT -A INPUT -p tcp -m conntrack –ctstate NEW,ESTABLISHED -m tcp –dport 8338 -j ACCEPT -A INPUT -p tcp -m conntrack –ctstate NEW,ESTABLISHED -m tcp –dport 10000 -j ACCEPT -A INPUT -s 192.168.1.0/24 -j ACCEPT -A INPUT -s 192.168.1.111/32 -j ACCEPT -A INPUT -s 192.168.1.222/32 -j ACCEPT -A INPUT -s 192.168.1.100/32 -j ACCEPT -A INPUT -s 192.168.1.123/32 -j ACCEPT -A INPUT -p tcp -m tcp -m multiport –dports 21,22,80,443,25,110,143,587,993,995,8338,10000 -j ACCEPT -A INPUT -i wlan0 -j ACCEPT -A INPUT -i eth0 -j ACCEPT -A INPUT -p tcp -m state –state NEW –dport 22 -j ACCEPT -A INPUT -s 192.168.1.222/32 -p tcp -m state –state NEW,RELATED,ESTABLISHED -m tcp –dport 22 -j ACCEPT -A INPUT -p tcp -m state –state NEW,RELATED,ESTABLISHED -m tcp –dport 22 -j DROP -A INPUT -p tcp -m tcp –dport 21 -j ACCEPT -A INPUT -p tcp -m tcp –dport 25 -j ACCEPT -A INPUT -p tcp -m tcp –dport 80 -j ACCEPT -A INPUT -p tcp -m tcp –dport 110 -j ACCEPT -A INPUT -p tcp -m tcp –dport 143 -j ACCEPT -A INPUT -p tcp -m tcp –dport 443 -j ACCEPT -A INPUT -p tcp -m tcp –dport 465 -j ACCEPT -A INPUT -p tcp -m tcp –dport 587 -j ACCEPT -A INPUT -p tcp -m tcp –dport 993 -j ACCEPT -A INPUT -p tcp -m tcp –dport 995 -j ACCEPT -A INPUT -p tcp -m tcp –dport 8338 -j ACCEPT -A INPUT -p tcp -m tcp –dport 10000 -j ACCEPT -A INPUT -p udp -m udp –sport 8442 –dport 1024:65535 -j ACCEPT -A INPUT -p udp -m state –state NEW,ESTABLISHED -m udp –dport 53 -j ACCEPT #-A INPUT -p udp -m udp –sport 53 –dport 1024:65535 -j ACCEPT -A INPUT -p udp -m udp –sport 53 -j ACCEPT -A INPUT -s 192.168.1.0/24 -p tcp -m conntrack –ctstate NEW,ESTABLISHED -m tcp –dport 3306 -j ACCEPT -A INPUT -s 192.168.1.100/32 -p tcp -m conntrack –ctstate NEW,ESTABLISHED -m tcp –dport 3306 -j ACCEPT -A INPUT -s 192.168.1.222/32 -p tcp -m conntrack –ctstate NEW,ESTABLISHED -m tcp –dport 3306 -j ACCEPT -A INPUT -s 192.168.1.111/32 -p tcp -m conntrack –ctstate NEW,ESTABLISHED -m tcp –dport 3306 -j ACCEPT -A INPUT -s 192.168.1.123/32 -p tcp -m conntrack –ctstate NEW,ESTABLISHED -m tcp –dport 3306 -j ACCEPT -A INPUT -i eth0 -p tcp -m conntrack –ctstate NEW,ESTABLISHED -m tcp –dport 3306 -j ACCEPT -A INPUT -s 192.168.1.0/24 -p tcp -m conntrack –ctstate NEW,ESTABLISHED -m tcp –dport 5432 -j ACCEPT -A INPUT -i eth0 -p tcp -m conntrack –ctstate NEW,ESTABLISHED -m tcp –dport 5432 -j ACCEPT -A INPUT -p tcp -m tcp –dport 3142 -j ACCEPT -A INPUT -p tcp -m conntrack –ctstate NEW,ESTABLISHED -m tcp –dport 22 -j ACCEPT -A INPUT -p tcp -m conntrack –ctstate ESTABLISHED -m tcp –sport 22 -j ACCEPT -A INPUT -p tcp -m state –state NEW -m tcp –dport 22 -j ACCEPT -A INPUT -p tcp -m tcp –dport 22 -j ACCEPT -A INPUT -s 192.168.1.222/32 -p tcp -m tcp –dport 22 -j ACCEPT -A INPUT -p tcp -m tcp –dport 22 -j DROP #-A INPUT -p tcp -m state –state NEW -m recent –set –name ssh –mask 255.255.255.255 –rsource -m tcp –dport 22 #-A INPUT -p tcp -m state –state NEW -m recent ! –rcheck –seconds 90 –hitcount 6 –name ssh –mask 255.255.255.255 –rsource -m tcp –dport 22 -j ACCEPT -A INPUT -p tcp –dport 80 -m limit –limit 20/minute –limit-burst 100 -j ACCEPT -A INPUT -s 192.168.1.0/24 -p tcp -m conntrack –ctstate NEW,ESTABLISHED -m tcp –dport 873 -j ACCEPT -A INPUT -p udp -m state –state NEW -m udp –dport 5353 -j ACCEPT -A INPUT -p icmp -m icmp –icmp-type 8 -j ACCEPT -A INPUT -p tcp -m tcp –dport 113 -j ACCEPT -A INPUT -m state –state NEW -p udp –dport 123 -j ACCEPT -A INPUT -p tcp -m tcp –dport 2049:2050 -j DROP -A INPUT -p tcp -m tcp –dport 6000:6063 -j DROP -A INPUT -p tcp -m tcp –dport 7000:7010 -j DROP -A INPUT -m limit –limit 5/min -j LOG –log-prefix “iptables denied: ” –log-level 7 -A INPUT -m conntrack –ctstate INVALID -j DROP -A INPUT -j REJECT –reject-with icmp-port-unreachable -A INPUT -j DROP -A INPUT -m state –state RELATED,ESTABLISHED -j ACCEPT #-A INPUT -p icmp -m icmp –icmp-type 8 -j REJECT –reject-with icmp-port-unreachable #-A INPUT -i eth0 -p icmp -m icmp –icmp-type 8 -j DROP -A INPUT -m state –state INVALID -j DROP -A FORWARD -j REJECT -A FORWARD -j DROP -A FORWARD -i wlan0 -o eth0 -m state –state RELATED,ESTABLISHED -j ACCEPT -A FORWARD -i eth0 -o wlan0 -j ACCEPT -A FORWARD -i eth0 -o wlan0 -m state –state RELATED,ESTABLISHED -j ACCEPT -A FORWARD -i wlan0 -o eth0 -j ACCEPT -A FORWARD -i eth0 -m state –state RELATED,ESTABLISHED -j ACCEPT -A OUTPUT -m state –state RELATED,ESTABLISHED -j ACCEPT -A OUTPUT -p udp -m udp –dport 53 -j ACCEPT -A OUTPUT -d 8.8.8.8/32 -p udp -m udp –dport 53 -j ACCEPT -A OUTPUT -d 8.8.4.4/32 -p udp -m udp –dport 53 -j ACCEPT -A OUTPUT -d 84.255.209.79/32 -p udp -m udp –dport 53 -j ACCEPT -A OUTPUT -d 84.255.210.79/32 -p udp -m udp –dport 53 -j ACCEPT #-A OUTPUT -p icmp -m icmp –icmp-type 8 -j DROP -A OUTPUT -m conntrack –ctstate ESTABLISHED -j ACCEPT -A OUTPUT -j ACCEPT -A OUTPUT -p udp -m udp -m multiport –dports 123 -m state –state NEW -j ACCEPT -A OUTPUT -p tcp -m conntrack –ctstate ESTABLISHED -m tcp –sport 80 -j ACCEPT -A OUTPUT -p tcp -m conntrack –ctstate ESTABLISHED -m tcp –sport 443 -j ACCEPT -A OUTPUT -p tcp -m conntrack –ctstate ESTABLISHED -m tcp –sport 21 -j ACCEPT -A OUTPUT -p tcp -m conntrack –ctstate ESTABLISHED -m tcp –sport 25 -j ACCEPT -A OUTPUT -p tcp -m conntrack –ctstate ESTABLISHED -m tcp –sport 143 -j ACCEPT -A OUTPUT -p tcp -m conntrack –ctstate ESTABLISHED -m tcp –sport 993 -j ACCEPT -A OUTPUT -p tcp -m conntrack –ctstate ESTABLISHED -m tcp –sport 110 -j ACCEPT -A OUTPUT -p tcp -m conntrack –ctstate ESTABLISHED -m tcp –sport 995 -j ACCEPT -A OUTPUT -p tcp -m conntrack –ctstate ESTABLISHED -m tcp –sport 3306 -j ACCEPT -A OUTPUT -p tcp -m conntrack –ctstate ESTABLISHED -m tcp –sport 8338 -j ACCEPT -A OUTPUT -p tcp -m conntrack –ctstate ESTABLISHED -m tcp –sport 10000 -j ACCEPT -A OUTPUT -o eth0 -p tcp -m conntrack –ctstate ESTABLISHED -m tcp –sport 3306 -j ACCEPT -A OUTPUT -p tcp -m conntrack –ctstate ESTABLISHED -m tcp –sport 5432 -j ACCEPT -A OUTPUT -o eth0 -p tcp -m conntrack –ctstate ESTABLISHED -m tcp –sport 5432 -j ACCEPT -A OUTPUT -p tcp -m conntrack –ctstate ESTABLISHED -m tcp –sport 22 -j ACCEPT -A OUTPUT -p tcp -m conntrack –ctstate NEW,ESTABLISHED -m tcp –dport 22 -j ACCEPT -A OUTPUT -p tcp -m conntrack –ctstate ESTABLISHED -m tcp –sport 873 -j ACCEPT -A OUTPUT -d 192.168.1.0/24 -j ACCEPT -A OUTPUT -d 192.168.1.100/32 -j ACCEPT -A OUTPUT -d 192.168.1.111/32 -j ACCEPT -A OUTPUT -d 192.168.1.123/32 -j ACCEPT -A OUTPUT -d 192.168.1.222/32 -j ACCEPT -A OUTPUT -p tcp -s 192.168.1.222/32 –dport 22 -j ACCEPT -A OUTPUT -p tcp –dport 22 -j DROP -N block-scan -A block-scan -p tcp –tcp-flags SYN,ACK,FIN,RST RST -m limit –limit 1/s -j RETURN -A block-scan -j DROP COMMIT ## Shranite datoteko in ustvarite še parametre za ipv6: sudo nano /tmp/v6 *nat :PREROUTING ACCEPT [0:0] :POSTROUTING ACCEPT [0:0] :OUTPUT ACCEPT [0:0] COMMIT *mangle :PREROUTING ACCEPT [0:0] :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] :POSTROUTING ACCEPT [0:0] COMMIT *raw :PREROUTING ACCEPT [0:0] :OUTPUT ACCEPT [0:0] COMMIT *filter :FORWARD ACCEPT [0:0] :INPUT DROP [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -i lo -j ACCEPT # Dissalow input – connections from outsite localhost -A INPUT -s ::1/128 ! -i lo -j REJECT # Accept traffic from internal interfaces -A INPUT ! -i eth0 -j ACCEPT # Accept traffic with the ACK flag set -A INPUT -p tcp -m tcp –tcp-flags ACK ACK -j ACCEPT # Allow incoming data that is part of a connection we established -A INPUT -m state –state ESTABLISHED -j ACCEPT # Allow data that is related to existing connections -A INPUT -m state –state RELATED -j ACCEPT # Accept responses to DNS queries UPD connedtion port ipv4 8442 open all ports from 1024 to 65535 -A INPUT -p udp -m udp –dport 1024:65535 –sport 8442 -j ACCEPT #-A INPUT -p udp -m udp –dport 1024:65535 –sport 8442 -j ACCEPT -A INPUT -p tcp -m tcp -m multiport -j ACCEPT –dports ftp,ssh,www,https,pop3,smtp,imap,imaps,pop3s,8338,4000,10000 ## Allow connections to our IDENT server -A INPUT -p tcp -m tcp –dport auth -j ACCEPT # Respond to pings -A INPUT -p icmp -m icmp –icmp-type echo-request -j ACCEPT Protect our NFS server -A INPUT -p tcp -m tcp –dport 2049:2050 -j DROP # Protect our X11 display server -A INPUT -p tcp -m tcp –dport 6000:6063 -j DROP # Protect our X font server -A INPUT -p tcp -m tcp –dport 7000:7010 -j DROP -A INPUT -j REJECT -A FORWARD -j REJECT COMMIT ## Shranite in preden namestite iptebles persistent modul oz. da se vam iptables parametri naložijo ob ponovnem zagonu strežnika ## prikliči instaliraj modul iptablas autostart: sudo iptables-restore < /tmp/v4 sudo ip6tables-restore < /tmp/v6 ## Namesti iptables modul persistent vsi odgovori YES /(dodal sem še ipset in fail2ban): sudo apt-get install iptables-persistent ipset iptables fail2ban -y sudo reboot # PREVERI ČE DELAJO BLOKADE IPTABLES TAKO: sudo iptables -vL sudo ip6tables -vL ### V PRIMERU DA VAN NE NALOŽI DIREKTIV KOPIRAJTE ZGORNJE DIREKTIVE ZA IPV4 IN IPV6: sudo nano /etc/iptables/rules.v4 ## TUKAJ ZGORNJE VAŠE PARAMETRE IPV4 sudo nano /etc/iptables/rules.v6 ## TUKAJ ZGORNJE VAŠE PARAMETRE IPV6 ##Fail2Ban požarni zid za apps in server: sudo apt install fail2ban -y sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local sudo nano /etc/fail2ban/jail.local enabled = true filter = apache-badbots ls /etc/fail2ban/filter.d/

### Namestitev UFW nekomplicirani požarni zid - Ni dobro za WEB Scado če ste admin strank !!!



sudo apt install ufw

sudo ufw enable -y

sudo ufw allow 80
sudo ufw allow 443
sudo ufw limit ssh/tcp
sudo ufw allow 25
sudo ufw allow 465
sudo ufw allow 587
sudo ufw allow 143
sudo ufw allow 993
sudo ufw allow 110
sudo ufw allow 995
sudo ufw allow 4000
sudo ufw allow 8442
sudo ufw allow 10000
#sudo ufw allow 20000
sudo ufw allow from 192.168.1.10 port 22
# Tvoj ip local npr. PC s katerega dostopate v terminal

Noip.com Namestitev aplikacije dinamični internet – DDNS:

### kot root@webscada: vaš hostname:

cd /usr/local/src/
sudo wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz
tar xf noip-duc-linux.tar.gz
sudo rm noip-duc-linux.tar.gz
cd noip-2.1.9-1/
sudo make install

cd /etc/
sudo nano rc.local
## ****rc.local...
sudo noip2
# Shrani

sudo shutdown -r now

sudo noip2 -S

 

16) Namestitev Požarnega zida za spletne aplikacije – fail2ban:

V terminalu zaženite spodnje komande:

sudo apt install fail2ban -y

sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local

sudo nano /etc/fail2ban/jail.local

enabled = true
filter = apache-badbots
# Za vklopit modul kot je zgoraj enable in ime filtra!!!

ls /etc/fail2ban/filter.d/

sudo service fail2ban restart
sudo service fail2ban status

Konfiguracija Fail2Ban za WEB Scado – sudo nano /etc/fail2ban/fail2ban.conf:

/etc/fail2ban/fail2ban.conf
# Fail2Ban main configuration file
#
# Comments: use '#' for comment lines and ';' (following a space) for inline comments
#
# Changes:  in most of the cases you should not modify this
#           file, but provide customizations in fail2ban.local file, e.g.:
#
# [Definition]
# loglevel = DEBUG
#

[Definition]

# Option: loglevel
# Notes.: Set the log level output.
#         CRITICAL
#         ERROR
#         WARNING
#         NOTICE
#         INFO
#         DEBUG
# Values: [ LEVEL ]  Default: ERROR
#
loglevel = INFO

# Option: logtarget
# Notes.: Set the log target. This could be a file, SYSLOG, STDERR or STDOUT.
#         Only one log target can be specified.
#         If you change logtarget from the default value and you are
#         using logrotate -- also adjust or disable rotation in the
#         corresponding configuration file
#         (e.g. /etc/logrotate.d/fail2ban on Debian systems)
# Values: [ STDOUT | STDERR | SYSLOG | SYSOUT | FILE ]  Default: STDERR
#
logtarget = /var/log/fail2ban.log

# Option: syslogsocket
# Notes: Set the syslog socket file. Only used when logtarget is SYSLOG
#        auto uses platform.system() to determine predefined paths
# Values: [ auto | FILE ]  Default: auto
syslogsocket = auto

# Option: socket
# Notes.: Set the socket file. This is used to communicate with the daemon. Do
#         not remove this file when Fail2ban runs. It will not be possible to
#         communicate with the server afterwards.
# Values: [ FILE ]  Default: /var/run/fail2ban/fail2ban.sock
#
socket = /var/run/fail2ban/fail2ban.sock

# Option: pidfile
# Notes.: Set the PID file. This is used to store the process ID of the
#         fail2ban server.
# Values: [ FILE ]  Default: /var/run/fail2ban/fail2ban.pid
#
pidfile = /var/run/fail2ban/fail2ban.pid

# Options: dbfile
# Notes.: Set the file for the fail2ban persistent data to be stored.
#         A value of ":memory:" means database is only stored in memory 
#         and data is lost when fail2ban is stopped.
#         A value of "None" disables the database.
# Values: [ None :memory: FILE ] Default: /var/lib/fail2ban/fail2ban.sqlite3
dbfile = /var/lib/fail2ban/fail2ban.sqlite3

# Options: dbpurgeage
# Notes.: Sets age at which bans should be purged from the database
# Values: [ SECONDS ] Default: 86400 (24hours)
dbpurgeage = 8d 

Konfiguracija fail2ban modulov – sudo nano /etc/fail2ban/local.jail:

Poglejte prispevek: https://oglasi.hopto.org/fail2ban-linux-pozarni-zid-nastavitev-za-wordpress-best-opcija-iptables-ufw/

/etc/fail2ban/local.jail
# # WARNING: heavily refactored in 0.9.0 release. Please review and # customize settings for your setup. # # Changes: in most of the cases you should not modify this # file, but provide customizations in jail.local file, # or separate .conf files under jail.d/ directory, e.g.: # # HOW TO ACTIVATE JAILS: # # YOU SHOULD NOT MODIFY THIS FILE. # # It will probably be overwritten or improved in a distribution update. # # Provide customizations in a jail.local file or a jail.d/customisation.local. # For example to change the default bantime for all jails and to enable the # ssh-iptables jail the following (uncommented) would appear in the .local file. # See man 5 jail.conf for details. # # [DEFAULT] # bantime = 1h # # [sshd] # enabled = true # # See jail.conf(5) man page for more information # Comments: use '#' for comment lines and ';' (following a space) for inline comments [INCLUDES] #before = paths-distro.conf before = paths-debian.conf # The DEFAULT allows a global definition of the options. They can be overridden # in each jail afterwards. [DEFAULT] # # MISCELLANEOUS OPTIONS # # "ignorself" specifies whether the local resp. own IP addresses should be ignored # (default is true). Fail2ban will not ban a host which matches such addresses. #ignorself = true # "ignoreip" can be a list of IP addresses, CIDR masks or DNS hosts. Fail2ban # will not ban a host which matches an address in this list. Several addresses # can be defined using space (and/or comma) separator. #ignoreip = 127.0.0.1/8 ::1 ignoreip = 127.0.0.1/8 ::1 192.168.0.1/24 # External command that will take an tagged arguments to ignore, e.g. <ip>, # and return true if the IP is to be ignored. False otherwise. # # ignorecommand = /path/to/command <ip> ignorecommand = # "bantime" is the number of seconds that a host is banned. bantime = 600m # A host is banned if it has generated "maxretry" during the last "findtime" # seconds. findtime = 600m # "maxretry" is the number of failures before a host get banned. maxretry = 3 # "backend" specifies the backend used to get files modification. # Available options are "pyinotify", "gamin", "polling", "systemd" and "auto". # This option can be overridden in each jail as well. # # pyinotify: requires pyinotify (a file alteration monitor) to be installed. # If pyinotify is not installed, Fail2ban will use auto. # gamin: requires Gamin (a file alteration monitor) to be installed. # If Gamin is not installed, Fail2ban will use auto. # polling: uses a polling algorithm which does not require external libraries. # systemd: uses systemd python library to access the systemd journal. # Specifying "logpath" is not valid for this backend. # See "journalmatch" in the jails associated filter config # auto: will try to use the following backends, in order: # pyinotify, gamin, polling. # # Note: if systemd backend is chosen as the default but you enable a jail # for which logs are present only in its own log files, specify some other # backend for that jail (e.g. polling) and provide empty value for # journalmatch. See https://github.com/fail2ban/fail2ban/issues/959#issuecomment-74901200 backend = auto # "usedns" specifies if jails should trust hostnames in logs, # warn when DNS lookups are performed, or ignore all hostnames in logs # # yes: if a hostname is encountered, a DNS lookup will be performed. # warn: if a hostname is encountered, a DNS lookup will be performed, # but it will be logged as a warning. # no: if a hostname is encountered, will not be used for banning, # but it will be logged as info. # raw: use raw value (no hostname), allow use it for no-host filters/actions (example user) usedns = warn # "logencoding" specifies the encoding of the log files handled by the jail # This is used to decode the lines from the log file. # Typical examples: "ascii", "utf-8" # # auto: will use the system locale setting logencoding = auto # "enabled" enables the jails. # By default all jails are disabled, and it should stay this way. # Enable only relevant to your setup jails in your .local or jail.d/*.conf # # true: jail will be enabled and log files will get monitored for changes # false: jail is not enabled enabled = false # "mode" defines the mode of the filter (see corresponding filter implementation for more info). mode = normal # "filter" defines the filter to use by the jail. # By default jails have names matching their filter name # filter = %(__name__)s[mode=%(mode)s] # # ACTIONS # # Some options used for actions # Destination email address used solely for the interpolations in # jail.{conf,local,d/*} configuration files. destemail = root@localhost # Sender email address used solely for some actions sender = root@<fq-hostname> # E-mail action. Since 0.8.1 Fail2Ban uses sendmail MTA for the # mailing. Change mta configuration parameter to mail if you want to # revert to conventional 'mail'. mta = sendmail # Default protocol protocol = tcp # Specify chain where jumps would need to be added in ban-actions expecting parameter chain chain = <known/chain> # Ports to be banned # Usually should be overridden in a particular jail port = 0:65535 # Format of user-agent https://tools.ietf.org/html/rfc7231#section-5.5.3 fail2ban_agent = Fail2Ban/%(fail2ban_version)s # # Action shortcuts. To be used to define action parameter # Default banning action (e.g. iptables, iptables-new, # iptables-multiport, shorewall, etc) It is used to define # action_* variables. Can be overridden globally or per # section within jail.local file banaction = iptables-multiport banaction_allports = iptables-allports # The simplest action to take: ban only action_ = %(banaction)s[name=%(__name__)s, bantime="%(bantime)s", port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"] # ban & send an e-mail with whois report to the destemail. action_mw = %(banaction)s[name=%(__name__)s, bantime="%(bantime)s", port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"] %(mta)s-whois[name=%(__name__)s, sender="%(sender)s", dest="%(destemail)s", protocol="%(protocol)s", chain="%(chain)s"] # ban & send an e-mail with whois report and relevant log lines # to the destemail. action_mwl = %(banaction)s[name=%(__name__)s, bantime="%(bantime)s", port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"] %(mta)s-whois-lines[name=%(__name__)s, sender="%(sender)s", dest="%(destemail)s", logpath=%(logpath)s, chain="%(chain)s"] # See the IMPORTANT note in action.d/xarf-login-attack for when to use this action # # ban & send a xarf e-mail to abuse contact of IP address and include relevant log lines # to the destemail. action_xarf = %(banaction)s[name=%(__name__)s, bantime="%(bantime)s", port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"] xarf-login-attack[service=%(__name__)s, sender="%(sender)s", logpath=%(logpath)s, port="%(port)s"] # ban IP on CloudFlare & send an e-mail with whois report and relevant log lines # to the destemail. action_cf_mwl = cloudflare[cfuser="%(cfemail)s", cftoken="%(cfapikey)s"] %(mta)s-whois-lines[name=%(__name__)s, sender="%(sender)s", dest="%(destemail)s", logpath=%(logpath)s, chain="%(chain)s"] # Report block via blocklist.de fail2ban reporting service API # # See the IMPORTANT note in action.d/blocklist_de.conf for when to use this action. # Specify expected parameters in file action.d/blocklist_de.local or if the interpolation # `action_blocklist_de` used for the action, set value of `blocklist_de_apikey` # in your `jail.local` globally (section [DEFAULT]) or per specific jail section (resp. in # corresponding jail.d/my-jail.local file). # action_blocklist_de = blocklist_de[email="%(sender)s", service=%(filter)s, apikey="%(blocklist_de_apikey)s", agent="%(fail2ban_agent)s"] # Report ban via badips.com, and use as blacklist # # See BadIPsAction docstring in config/action.d/badips.py for # documentation for this action. # # NOTE: This action relies on banaction being present on start and therefore # should be last action defined for a jail. # action_badips = badips.py[category="%(__name__)s", banaction="%(banaction)s", agent="%(fail2ban_agent)s"] # # Report ban via badips.com (uses action.d/badips.conf for reporting only) # action_badips_report = badips[category="%(__name__)s", agent="%(fail2ban_agent)s"] # Report ban via abuseipdb.com. # # See action.d/abuseipdb.conf for usage example and details. # action_abuseipdb = abuseipdb # Choose default action. To change, just override value of 'action' with the # interpolation to the chosen action shortcut (e.g. action_mw, action_mwl, etc) in jail.local # globally (section [DEFAULT]) or per specific section action = %(action_)s # # JAILS # # # SSH servers # [sshd] # To use more aggressive sshd modes set filter parameter "mode" in jail.local: # normal (default), ddos, extra or aggressive (combines all). # See "tests/files/logs/sshd" or "filter.d/sshd.conf" for usage example and details. #mode = normal port = ssh logpath = %(sshd_log)s backend = %(sshd_backend)s enabled = true filter = sshd maxretry = 3 bantime = -1 banaction = %(banaction_allports)s [dropbear] port = ssh logpath = %(dropbear_log)s backend = %(dropbear_backend)s [selinux-ssh] port = ssh logpath = %(auditd_log)s # # HTTP servers # [apache-auth] enabled = true filter = apache-auth port = http,https logpath = %(apache_error_log)s maxretry = 2 bantime = 6h banaction = %(banaction_allports)s [apache-badbots] enabled = true filter = apache-badbots port = http,https logpath = %(apache_access_log)s bantime = 6h maxretry = 1 banaction = %(banaction_allports)s [apache-noscript] enabled = true filter = apache-noscript port = http,https logpath = %(apache_error_log)s maxretry = 1 bantime = 6h banaction = %(banaction_allports)s [apache-overflows] enabled = true filter = apache-overflows port = http,https logpath = %(apache_error_log)s maxretry = 2 bantime = 6h banaction = %(banaction_allports)s [apache-nohome] enabled = true filter = apache-nohome port = http,https logpath = %(apache_error_log)s maxretry = 2 bantime = 6h banaction = %(banaction_allports)s [apache-botsearch] enabled = true filter = apache-botsearch port = http,https logpath = %(apache_error_log)s maxretry = 2 bantime = 6h banaction = %(banaction_allports)s [apache-fakegooglebot] enabled = true filter = apache-fakegooglebot port = http,https logpath = %(apache_access_log)s maxretry = 1 ignorecommand = %(ignorecommands_dir)s/apache-fakegooglebot <ip> bantime = 6h banaction = %(banaction_allports)s [apache-modsecurity] enabled = true filter = apache-modsecurity port = http,https logpath = %(apache_error_log)s maxretry = 2 bantime = 6h banaction = %(banaction_allports)s [apache-shellshock] enabled = true filter = apache-shellshock port = http,https logpath = %(apache_error_log)s maxretry = 1 bantime = 6h banaction = %(banaction_allports)s ######################################################################## [openhab-auth] filter = openhab action = iptables-allports[name=NoAuthFailures] logpath = /opt/openhab/logs/request.log [nginx-http-auth] port = http,https logpath = %(nginx_error_log)s # To use 'nginx-limit-req' jail you should have `ngx_http_limit_req_module` # and define `limit_req` and `limit_req_zone` as described in nginx documentation # http://nginx.org/en/docs/http/ngx_http_limit_req_module.html # or for example see in 'config/filter.d/nginx-limit-req.conf' [nginx-limit-req] port = http,https logpath = %(nginx_error_log)s [nginx-botsearch] port = http,https logpath = %(nginx_error_log)s maxretry = 2 ######################################################################## ######################################################################## # Ban attackers that try to use PHP's URL-fopen() functionality # through GET/POST variables. - Experimental, with more than a year # of usage in production environments. [php-url-fopen] enabled = true filter = php-url-fopen port = http,https logpath = %(apache_access_log)s maxretry = 3 bantime = -1 banaction = %(banaction_allports)s [suhosin] port = http,https logpath = %(suhosin_log)s [lighttpd-auth] # Same as above for Apache's mod_auth # It catches wrong authentifications port = http,https logpath = %(lighttpd_error_log)s # # Webmail and groupware servers # [roundcube-auth] port = http,https logpath = %(roundcube_errors_log)s # Use following line in your jail.local if roundcube logs to journal. #backend = %(syslog_backend)s [openwebmail] port = http,https logpath = /var/log/openwebmail.log [horde] port = http,https logpath = /var/log/horde/horde.log [groupoffice] port = http,https logpath = /home/groupoffice/log/info.log [sogo-auth] # Monitor SOGo groupware server # without proxy this would be: # port = 20000 port = http,https logpath = /var/log/sogo/sogo.log [tine20] logpath = /var/log/tine20/tine20.log port = http,https # # Web Applications # # [drupal-auth] port = http,https logpath = %(syslog_daemon)s backend = %(syslog_backend)s [guacamole] port = http,https logpath = /var/log/tomcat*/catalina.out [monit] #Ban clients brute-forcing the monit gui login port = 2812 logpath = /var/log/monit ######################################################################## [webmin-auth] enabled = true filter = webmin-auth port = 10000 logpath = %(syslog_authpriv)s backend = %(syslog_backend)s maxretry = 6 bantime = -1 banaction = %(banaction_allports)s ######################################################################## [froxlor-auth] port = http,https logpath = %(syslog_authpriv)s backend = %(syslog_backend)s # # HTTP Proxy servers # # [squid] port = 80,443,3128,8080 logpath = /var/log/squid/access.log [3proxy] port = 3128 logpath = /var/log/3proxy.log # # FTP servers # [proftpd] port = ftp,ftp-data,ftps,ftps-data logpath = %(proftpd_log)s backend = %(proftpd_backend)s [pureftpd] port = ftp,ftp-data,ftps,ftps-data logpath = %(pureftpd_log)s backend = %(pureftpd_backend)s [gssftpd] port = ftp,ftp-data,ftps,ftps-data logpath = %(syslog_daemon)s backend = %(syslog_backend)s [wuftpd] port = ftp,ftp-data,ftps,ftps-data logpath = %(wuftpd_log)s backend = %(wuftpd_backend)s [vsftpd] # or overwrite it in jails.local to be # logpath = %(syslog_authpriv)s # if you want to rely on PAM failed login attempts # vsftpd's failregex should match both of those formats port = ftp,ftp-data,ftps,ftps-data logpath = %(vsftpd_log)s # # Mail servers # # ASSP SMTP Proxy Jail [assp] port = smtp,465,submission logpath = /root/path/to/assp/logs/maillog.txt [courier-smtp] port = smtp,465,submission logpath = %(syslog_mail)s backend = %(syslog_backend)s [postfix] # To use another modes set filter parameter "mode" in jail.local: mode = more port = smtp,465,submission logpath = %(postfix_log)s backend = %(postfix_backend)s [postfix-rbl] filter = postfix[mode=rbl] port = smtp,465,submission logpath = %(postfix_log)s backend = %(postfix_backend)s maxretry = 1 [sendmail-auth] port = submission,465,smtp logpath = %(syslog_mail)s backend = %(syslog_backend)s [sendmail-reject] # To use more aggressive modes set filter parameter "mode" in jail.local: # normal (default), extra or aggressive # See "tests/files/logs/sendmail-reject" or "filter.d/sendmail-reject.conf" for usage example and details. #mode = normal port = smtp,465,submission logpath = %(syslog_mail)s backend = %(syslog_backend)s [qmail-rbl] filter = qmail port = smtp,465,submission logpath = /service/qmail/log/main/current # dovecot defaults to logging to the mail syslog facility # but can be set by syslog_facility in the dovecot configuration. [dovecot] port = pop3,pop3s,imap,imaps,submission,465,sieve logpath = %(dovecot_log)s backend = %(dovecot_backend)s [sieve] port = smtp,465,submission logpath = %(dovecot_log)s backend = %(dovecot_backend)s [solid-pop3d] port = pop3,pop3s logpath = %(solidpop3d_log)s [exim] # see filter.d/exim.conf for further modes supported from filter: #mode = normal port = smtp,465,submission logpath = %(exim_main_log)s [exim-spam] port = smtp,465,submission logpath = %(exim_main_log)s [kerio] port = imap,smtp,imaps,465 logpath = /opt/kerio/mailserver/store/logs/security.log # # Mail servers authenticators: might be used for smtp,ftp,imap servers, so # all relevant ports get banned # [courier-auth] port = smtp,465,submission,imap,imaps,pop3,pop3s logpath = %(syslog_mail)s backend = %(syslog_backend)s [postfix-sasl] filter = postfix[mode=auth] port = smtp,465,submission,imap,imaps,pop3,pop3s # You might consider monitoring /var/log/mail.warn instead if you are # running postfix since it would provide the same log lines at the # "warn" level but overall at the smaller filesize. logpath = %(postfix_log)s backend = %(postfix_backend)s [perdition] port = imap,imaps,pop3,pop3s logpath = %(syslog_mail)s backend = %(syslog_backend)s [squirrelmail] port = smtp,465,submission,imap,imap2,imaps,pop3,pop3s,http,https,socks logpath = /var/lib/squirrelmail/prefs/squirrelmail_access_log [cyrus-imap] port = imap,imaps logpath = %(syslog_mail)s backend = %(syslog_backend)s [uwimap-auth] port = imap,imaps logpath = %(syslog_mail)s backend = %(syslog_backend)s # # # DNS servers # # !!! WARNING !!! # Since UDP is connection-less protocol, spoofing of IP and imitation # of illegal actions is way too simple. Thus enabling of this filter # might provide an easy way for implementing a DoS against a chosen # victim. See # http://nion.modprobe.de/blog/archives/690-fail2ban-+-dns-fail.html # Please DO NOT USE this jail unless you know what you are doing. # # IMPORTANT: see filter.d/named-refused for instructions to enable logging # This jail blocks UDP traffic for DNS requests. # [named-refused-udp] # # filter = named-refused # port = domain,953 # protocol = udp # logpath = /var/log/named/security.log # IMPORTANT: see filter.d/named-refused for instructions to enable logging # This jail blocks TCP traffic for DNS requests. [named-refused] port = domain,953 logpath = /var/log/named/security.log [nsd] port = 53 action = %(banaction)s[name=%(__name__)s-tcp, port="%(port)s", protocol="tcp", chain="%(chain)s", actname=%(banaction)s-tcp] %(banaction)s[name=%(__name__)s-udp, port="%(port)s", protocol="udp", chain="%(chain)s", actname=%(banaction)s-udp] logpath = /var/log/nsd.log # # Miscellaneous # [asterisk] port = 5060,5061 action = %(banaction)s[name=%(__name__)s-tcp, port="%(port)s", protocol="tcp", chain="%(chain)s", actname=%(banaction)s-tcp] %(banaction)s[name=%(__name__)s-udp, port="%(port)s", protocol="udp", chain="%(chain)s", actname=%(banaction)s-udp] %(mta)s-whois[name=%(__name__)s, dest="%(destemail)s"] logpath = /var/log/asterisk/messages maxretry = 10 [freeswitch] port = 5060,5061 action = %(banaction)s[name=%(__name__)s-tcp, port="%(port)s", protocol="tcp", chain="%(chain)s", actname=%(banaction)s-tcp] %(banaction)s[name=%(__name__)s-udp, port="%(port)s", protocol="udp", chain="%(chain)s", actname=%(banaction)s-udp] %(mta)s-whois[name=%(__name__)s, dest="%(destemail)s"] logpath = /var/log/freeswitch.log maxretry = 10 # To log wrong MySQL access attempts add to /etc/my.cnf in [mysqld] or # equivalent section: # log-warning = 2 # # for syslog (daemon facility) # [mysqld_safe] # syslog # # for own logfile # [mysqld] # log-error=/var/log/mysqld.log [mysqld-auth] enabled = true filter = mysqld-auth port = 3306 logpath = %(mysql_log)s backend = %(mysql_backend)s maxretry = 3 bantime = -1 banaction = %(banaction_allports)s ######################################################################## # Log wrong MongoDB auth (for details see filter 'filter.d/mongodb-auth.conf') [mongodb-auth] # change port when running with "--shardsvr" or "--configsvr" runtime operation port = 27017 logpath = /var/log/mongodb/mongodb.log # Jail for more extended banning of persistent abusers # !!! WARNINGS !!! # 1. Make sure that your loglevel specified in fail2ban.conf/.local # is not at DEBUG level -- which might then cause fail2ban to fall into # an infinite loop constantly feeding itself with non-informative lines # 2. Increase dbpurgeage defined in fail2ban.conf to e.g. 648000 (7.5 days) # to maintain entries for failed logins for sufficient amount of time [recidive] enabled = true filter = recidive logpath = /var/log/fail2ban.log banaction = %(banaction_allports)s bantime = 2w findtime = 2d maxretry = 2 # Generic filter for PAM. Has to be used with action which bans all # ports such as iptables-allports, shorewall [pam-generic] # pam-generic filter can be customized to monitor specific subset of 'tty's banaction = %(banaction_allports)s logpath = %(syslog_authpriv)s backend = %(syslog_backend)s enabled = true filter = pam-generic maxretry = 6 bantime = -1 [xinetd-fail] banaction = iptables-multiport-log logpath = %(syslog_daemon)s backend = %(syslog_backend)s maxretry = 2 # stunnel - need to set port for this [stunnel] logpath = /var/log/stunnel4/stunnel.log [ejabberd-auth] port = 5222 logpath = /var/log/ejabberd/ejabberd.log [counter-strike] logpath = /opt/cstrike/logs/L[0-9]*.log # Firewall: http://www.cstrike-planet.com/faq/6 tcpport = 27030,27031,27032,27033,27034,27035,27036,27037,27038,27039 udpport = 1200,27000,27001,27002,27003,27004,27005,27006,27007,27008,27009,27010,27011,27012,27013,27014,27015 action = %(banaction)s[name=%(__name__)s-tcp, port="%(tcpport)s", protocol="tcp", chain="%(chain)s", actname=%(banaction)s-tcp] %(banaction)s[name=%(__name__)s-udp, port="%(udpport)s", protocol="udp", chain="%(chain)s", actname=%(banaction)s-udp] # consider low maxretry and a long bantime # nobody except your own Nagios server should ever probe nrpe [nagios] logpath = %(syslog_daemon)s ; nrpe.cfg may define a different log_facility backend = %(syslog_backend)s maxretry = 1 [oracleims] # see "oracleims" filter file for configuration requirement for Oracle IMS v6 and above logpath = /opt/sun/comms/messaging64/log/mail.log_current banaction = %(banaction_allports)s [directadmin] logpath = /var/log/directadmin/login.log port = 2222 [portsentry] logpath = /var/lib/portsentry/portsentry.history maxretry = 1 [pass2allow-ftp] enabled = true # this pass2allow example allows FTP traffic after successful HTTP authentication port = ftp,ftp-data,ftps,ftps-data # knocking_url variable must be overridden to some secret value in jail.local knocking_url = /preverjanje/ filter = apache-pass[knocking_url="%(knocking_url)s"] # access log of the website with HTTP auth logpath = %(apache_access_log)s blocktype = RETURN returntype = DROP action = %(action_)s[blocktype=%(blocktype)s, returntype=%(returntype)s] bantime = 1h maxretry = 1 findtime = 1 [murmur] # AKA mumble-server port = 64738 action = %(banaction)s[name=%(__name__)s-tcp, port="%(port)s", protocol=tcp, chain="%(chain)s", actname=%(banaction)s-tcp] %(banaction)s[name=%(__name__)s-udp, port="%(port)s", protocol=udp, chain="%(chain)s", actname=%(banaction)s-udp] logpath = /var/log/mumble-server/mumble-server.log [screensharingd] # For Mac OS Screen Sharing Service (VNC) logpath = /var/log/system.log logencoding = utf-8 [haproxy-http-auth] # HAProxy by default doesn't log to file you'll need to set it up to forward # logs to a syslog server which would then write them to disk. # See "haproxy-http-auth" filter for a brief cautionary note when setting # maxretry and findtime. logpath = /var/log/haproxy.log [slapd] port = ldap,ldaps logpath = /var/log/slapd.log [domino-smtp] port = smtp,ssmtp logpath = /home/domino01/data/IBM_TECHNICAL_SUPPORT/console.log [phpmyadmin-syslog] port = http,https logpath = %(syslog_authpriv)s backend = %(syslog_backend)s [zoneminder] # Zoneminder HTTP/HTTPS web interface auth # Logs auth failures to apache2 error log port = http,https logpath = %(apache_error_log)s [apache-myadmin] enabled = true filter = apache-myadmin port = http,https logpath = %(apache_access_log)s maxretry = 6 bantime = -1 banaction = %(banaction_allports)s #mode = aggressive [error] enabled = true filter = error port = http,https logpath = %(apache_access_log)s maxretry = 9 bantime = 24h banaction = %(banaction_allports)s #mode = aggressive #findtime = 6 ### DDOS PROTECT POST GEST #[http-get-dos] #enabled = true #filter = http-get-dos #port = http,https #logpath = %(apache_access_log)s #maxretry = 100 #findtime = 30 #bantime = 24h #banaction = %(banaction_allports)s #[http-post-dos] #enabled = true #filter = http-post-dos #port = http,https #logpath = %(apache_access_log)s #maxretry = 60 #findtime = 29 #bantime = 24h #banaction = %(banaction_allports)s # WEB SCADA LOGIN PROTECT [webscada] enabled = true filter = webscada port = http,https logpath = %(apache_access_log)s maxretry = 6 bantime = 24h banaction = %(banaction_allports)s