Linux vServer richtig absichern in 7 Schritten – IT-Basics

In diesem Video zeige ich euch, wie Ihr in 7 Schritten euren Linux vServer absichern und damit vor Angreifern schützen könnt.

» Erwähnte Videos:
Fail2Ban für Nextcloud einrichten: https://www.youtube.com/watch?v=nqz1IavVMUI
Automatische Update einrichten: https://cc.apfelcast.com/0nq9u

Im Video verwendete Befehle:

1. SSH Rot Login Deaktivieren:

## create new user
adduser srvadmin

## add user to sudo group
usermod -aG sudo srvadmin

## disable Login in settings
nano /etc/ssh/sshd_config

change "PermitRootLogin" to "no"


2. Change SSH Port 

## open SSH config file
nano /etc/ssh/sshd_config 

replace Port number

## restart ssh 
service ssh restart

3. Use SSH Key to Login

## create key
ssh-keygen -t rsa

## Login to remote Server and open file ##
nano ~/.ssh/authorized_keys

## copy public-key from local machine and add to file ##
cat ~/.ssh/id_rsa.pub

4. Configure internal firewall

## install ufw
apt install ufw

## configure ufw

ufw default deny
ufw allow 1055
ufw allow 80
ufw allow 443
ufw enable

ufw status


5. Install & Configure Fail2Ban

## install fail2ban
apt install fail2ban
systemctl enable fail2ban

## copy conf
cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local

## edit conf
nano /etc/fail2ban/jail.local

## configure for ssh
[sshd]
maxretry  = 3
findtime  = 1d
bantime   = 1w
port    = ssh
logpath = %(sshd_log)s
backend = %(sshd_backend)s


## restart fail2ban
systemctl restart fail2ban

## check service 
fail2ban-client ping

fail2ban-client status sshd


6. Disable IPv6

## open config
nano /etc/sysctl.d/99-sysctl.conf

## add the follwoing lines at the buttom
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

## execute changes
sysctl -p

## check if disableing worked
cat /proc/sys/net/ipv6/conf/all/disable_ipv6

apfelcast Support

Du benötigst Unterstützung bei deinem Projekt oder hast Fragen zur Umsetzung?
Dann melde ich gern bei uns!

Ähnliche Beiträge