Servereinrichtung: Unterschied zwischen den Versionen
KKeine Bearbeitungszusammenfassung |
KKeine Bearbeitungszusammenfassung |
||
| Zeile 77: | Zeile 77: | ||
<ul> | <ul> | ||
<li>systemctl restart fail2ban | <li>systemctl restart fail2ban | ||
<li>fail2ban-client status sshd | <li>fail2ban-client status sshd | ||
---- | |||
<li><p>apt install snapd</p></li> | <li><p>apt install snapd</p></li> | ||
<li><p>snap install --classic certbot</p></li> | <li><p>snap install --classic certbot</p></li> | ||
Aktuelle Version vom 21. Januar 2024, 11:19 Uhr
Servereinrichtung (mit Ubuntu und Apache)
Start Timeline
ssh-Zugriff mit root einrichten
root .bashrc ändern
#my own PS1="\[\e[1;31m\]PROD\[\e[0m\] $PS1 " mycpsave() { cp $1 $1.$(date +"%Y%m%d.%H%M%S%N"); }; export -f mycpsaveroot neues Passwort erstellt
useradd -m -s /bin/bash -c “Vorname Nachname” username
usermod -aG sudo username
passwd username
userhome .bashrc ändern
#my own PS1="\[\e[1;31m\]TEST\[\e[0m\] $PS1 " mycpsave() { cp $1 $1.$(date +"%Y%m%d.%H%M%S%N"); }; export -f mycpsave export PATH=~/bin:$PATH- mkdir .ssh
- cp /root/.ssh/authorized_keys .ssh/
- chown -R username:group.ssh/
nano /etc/ssh/sshd_config
PermitRootLogin no
dpkg-reconfigure dash
timedatectl
⚠ Zeitsynchronisation überprüfen systemctl status systemd-timesyncd timedatectl set-ntp true
apt install mc
apt install net-tools
apt update
apt dist-upgrade
apt install ufw
ufw app list
ufw allow OpenSSH
ufw enable
ufw status verbose
- DNS der Domain angepasst auf die IP des Servers
apt install mariadb-server
mysql_secure_installation
SQL-Anbindung mit PHP prüfen siehe Digital Ocean oder hier mit Apache
apt install apache2 php libapache2-mod-php
a2enmod ssl
apachectl configtest
systemctl restart apache2
usermod -aG www-data username
nano 001-sitename.de.conf
a2ensite 001-sitename.de.conf
ein paar Verzeichnisse erstellt in html und sitename.de/html
phpinfo.php erstellt
chown -R user:www-data /var/www/
apt install fail2ban
systemctl status fail2ban
cd /etc/fail2ban
cp jail.conf jail.local
nano jail.local
bantime = 30m findtime = 15m maxretry = 3 . . . [apache-auth][apache-badbots] enabled = true . . .
ℹ️ im home-Verzeichnis von username.
ℹ️ Erst SSH erlauben, bevor die Firewall arbeitet....
- systemctl restart fail2ban
- fail2ban-client status sshd
apt install snapd
snap install --classic certbot
ln -s /snap/bin/certbot /usr/bin/certbot
certbot --apache
certbot --apache –register-unsafely-without-email
letsencrypt --apache -d sitename.de,www.sitename.de,webmin.sitename.de
certbot renew --dry-run
sudo certbot certificates
systemctl list-timers
apt install libapache2-mod-wsgi-py3
nano /etc/apache2/conf-available/mod-wsgi.conf
WSGIScriptAlias /test /var/www/sitename.de/html/test_wsgi.py
nano test_wsgi.py
im Website-Stammverzeichnis: def application(environ,start_response): status = '200 OK' html = b'<html>\n' \ b'<body>\n' \ b' Hooray, mod_wsgi is working\n' \ b'</body>\n' \ b'</html>\n' response_header = [('Content-type','text/html')] start_response(status,response_header) return [html]a2enmod wsgi
apachectl configtest
- systemctl reload apache2
nano /etc/apt/sources.list
✍ deb https://download.webmin.com/download/repository sarge contrib
cat jcameron-key.asc | gpg --dearmor >/etc/apt/trusted.gpg.d/jcameron-key.gpg
apt install apt-transport-https
apt update
apt install webmin
systemctl status webmin
ufw allow 10000
Webmin Installationshilfe oder bei Digital Ocean
Webmin Modul “certmgr” installiert
⚠️ der Downloadlink stimmt nicht in der Webmin-Oberfläche: “www...” muss mit “http://download.webmin.com/download/modules” ersetzt werden.
⚠ der Downloadlink stimmt nicht in der Webmin-Oberfläche: “www...” muss mit “http://download.webmin.com/download/modules” ersetzt werden
Snapshot ncubuntua20230204s001
- Datenbank astroneth mit Berechtigung erstellt:
CREATE DATABASE astroneth;
SELECT user FROM mysql.user;
CREATE USER 'holger'@'localhost' IDENTIFIED BY 'sicheresPasswort';
GRANT ALL PRIVILEGES ON *.* TO 'holger'@'localhost';
CREATE USER 'holast'@'localhost' IDENTIFIED BY 'sicheresPasswort';
GRANT ALL PRIVILEGES ON astroneth . * TO 'holast'@'localhost';
FLUSH PRIVILEGES;
- Tabellen über Webmin importiert
- Datenbank anwiki mit Berechtigung erstellt:
CREATE DATABASE anwiki;
SELECT user FROM mysql.user;
CREATE USER 'holwiki'@'localhost' IDENTIFIED BY 'sicheresPasswort';
GRANT ALL PRIVILEGES ON anwiki . * TO 'holwiki'@'localhost';
FLUSH PRIVILEGES;
- Tabellen über Webmin importiert
- Wiki kopiert und localsettings.php angepasst
- Virtual-Hosts-Sites astroneth (001-anhome.conf) und holgerneth (001-mediawiki.conf) erstellt
Snapshot ncubunua20230407s001
ToDo
- ✍️ ToDo: eigene Fehlerseiten
- ✍️ ToDo: fail2ban und SSH-Port prüfen
zurück zur ==> Hauptseite