Servereinrichtung: Unterschied zwischen den Versionen

Aus AstroNeth-Wiki
Zur Navigation springen Zur Suche springen
Die Seite wurde neu angelegt: „<span id="server-ncubuntua"></span> = Server ncubuntua = <span id="start-timeline"></span> == Start Timeline == <ul> <li><p>root .bashrc ändern</p> <pre>#my own PS1="\[\e[1;31m\]PROD\[\e[0m\] $PS1 " mycpsave() { cp $1 $1.$(date +"%Y%m%d.%H%M%S%N"); }; export -f mycpsave </pre></li> <li><p>root neues Passwort erstellt</p></li> <li><p>useradd -m -s /bin/bash -c “Holger Neth” holger</p></li> <li><p>usermod -aG sudo holger</p></li>…“
 
Keine Bearbeitungszusammenfassung
Zeile 1: Zeile 1:
<span id="server-ncubuntua"></span>
<span id="server-ncubuntua"></span>
= Server ncubuntua =
= [[Servereinrichtung|Servereinrichtung (mit Ubuntu und Apache)]] =


<span id="start-timeline"></span>
<span id="start-timeline"></span>
Zeile 12: Zeile 12:
export -f mycpsave  </pre></li>
export -f mycpsave  </pre></li>
<li><p>root neues Passwort erstellt</p></li>
<li><p>root neues Passwort erstellt</p></li>
<li><p>useradd -m -s /bin/bash -c “Holger Neth” holger</p></li>
<li><p>useradd -m -s /bin/bash -c “Vorname Nachname” username</p></li>
<li><p>usermod -aG sudo holger</p></li>
<li><p>usermod -aG sudo username</p></li>
<li><p>passwd holger</p></li>
<li><p>passwd username</p></li>
<li><p>holger .bashrc ändern</p>
<li><p>holger .bashrc ändern</p>
<pre>#my own
<pre>#my own
Zeile 21: Zeile 21:
export -f mycpsave
export -f mycpsave
export PATH=~/bin:$PATH</pre></li>
export PATH=~/bin:$PATH</pre></li>
<li><pre>ℹ im home-Verzeichnis von holger</pre>
<li><pre>ℹ im home-Verzeichnis von username</pre>
<ul>
<ul>
<li>mkdir .ssh</li>
<li>mkdir .ssh</li>
<li>cp /root/.ssh/authorized_keys .ssh/</li>
<li>cp /root/.ssh/authorized_keys .ssh/</li>
<li>chown -R holger:holger .ssh/</li></ul>
<li>chown -R username:group.ssh/</li></ul>
</li>
</li>
<li><p>nano /etc/ssh/sshd_config</p>
<li><p>nano /etc/ssh/sshd_config</p>
Zeile 56: Zeile 56:
<li><p>apachectl configtest</p></li>
<li><p>apachectl configtest</p></li>
<li><p>systemctl restart apache2</p></li>
<li><p>systemctl restart apache2</p></li>
<li><p>usermod -aG www-data holger</p></li>
<li><p>usermod -aG www-data username</p></li>
<li><p>nano 001-astroneth.de.conf</p></li>
<li><p>nano 001-sitename.de.conf</p></li>
<li><span id="a2ensite-001-astroneth.de.conf"></span>
<li><p>a2ensite 001-sitename.de.conf</p></li>
== a2ensite 001-astroneth.de.conf ==
<li><p>ein paar Verzeichnisse erstellt in html und sitename.de/html</p></li>
</li>
<li><p>ein paar Verzeichnisse erstellt in html und astroneth.eu/html</p></li>
<li><p>phpinfo.php erstellt</p></li>
<li><p>phpinfo.php erstellt</p></li>
<li><span id="chown--r-holgerwww-data-varwww"></span>
<li><p>chown -R user:www-data /var/www/</p></li>
== chown -R holger:www-data /var/www/ ==
</li>
<li><p>apt install fail2ban</p></li>
<li><p>apt install fail2ban</p></li>
<li><p>systemctl status fail2ban</p></li>
<li><p>systemctl status fail2ban</p></li>
Zeile 78: Zeile 74:


enabled = true
enabled = true
. . .</pre></li>
. . .</pre></li></ul>
<li><span id="systemctl-restart-fail2ban"></span>
 
<ul>
<li>
== systemctl restart fail2ban ==
== systemctl restart fail2ban ==
</li>
</li>

Version vom 4. Februar 2023, 20:27 Uhr

Servereinrichtung (mit Ubuntu und Apache)

Start Timeline

  • 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 mycpsave  
  • root neues Passwort erstellt

  • useradd -m -s /bin/bash -c “Vorname Nachname” username

  • usermod -aG sudo username

  • passwd username

  • holger .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
  • ℹ im home-Verzeichnis von username
    • 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

    ⚠️ Erst SSH erlauben, bevor die Firewall arbeitet...
  • 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

  • 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
    . . .
  • systemctl restart fail2ban

  • 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 astroneth.eu,www.astroneth.eu,webmin.astroneth.eu

  • certbot renew –dry-run

  • systemctl list-timers

  • apt install libapache2-mod-wsgi-py3

  • nano /etc/apache2/conf-available/mod-wsgi.conf

      WSGIScriptAlias /home /var/www/astroneth.eu/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 
  • wget https://download.webmin.com/jcameron-key.asc

  • 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

Snapshot ncubunua20230204s001


zurück zur ==> Hauptseite