Securizare VPS / SemiDedicat / Dedicat

Salutare,

In acest tutorial va voi prezenta cum sa securizati un server(VPS, VDS, Dedicat).

De obicei, aceste probleme de securitate sunt rezolvate de catre compania de hosting, dar este indicat ca si dumneavoastra sa invatati cate ceva despre variatele metode de securizare ale unui server virtual privat. Din momentul in care dumneavoastra ati achizitionat un VPS, veti avea o multime de posibilitati si o multime de amenintari de securitate.

Iata cateva dintre metodele de securizare de baza in cazul unui server virtual privat, pe care ar trebui sa le invatati:

In primul rand trebuie sa protejati login-ul ssh care se realizeaza prin:

Schimbarea portului SSH:

nano /etc/ssh/sshd_config

Si in fisier editati:

Port 2222(sau oricare altul)
UseDNS No
ListenAddress AdresaIP(in cazul in care serverul are mai multe adrese IP

Apoi instalati fail2ban:

yum install epel-release -y
systemctl enable fail2ban

Editam configul fail2ban:

nano /etc/fail2ban/jail.local

Stergeti totul si introduceti:

[DEFAULT]
# Ban hosts for one hour:
bantime = 3600

# Override /etc/fail2ban/jail.d/00-firewalld.conf:
banaction = iptables-multiport

[sshd]
enabled = true

Restartam serviciul:

systemctl restart fail2ban

In cazul in care cineva ia acces pe serverul dvs. cel mai bine e ca sa primiti notificari atunci cand cineva acceseaza serverul. Pentru asta trebuie sa:

Creem fisier “/etc/prelogin“:

touch /etc/prelogin
nano /etc/prelogin

In acesta adaugam:

#################################################################
# Welcome to RCenter.Eu - Network
# All connections are monitored and recorded
# Disconnect IMMEDIATELY if you are not an authorized user!
#################################################################

apoi executati in terminal:

echo "Banner /etc/prelogin" >> /etc/ssh/sshd_config

editam “~/.bashrc“:

nano ~/.bashrc

si adaugam:

IP="$(echo $SSH_CONNECTION | cut -d " " -f 1)"
HOSTNAME=$(hostname)
NOW=$(date +"%e %b %Y, %a %r")

echo -e 'Someone from '$IP' logged into '$HOSTNAME' on '$NOW'.' | mail -s 'SSH Login Notification' office@rcenter.eu

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>