Outils pour utilisateurs

Outils du site


admin:services:apt-dater

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
admin:services:apt-dater [2017/12/02 00:54] – [Ajout d'un utilisateur dédié] Ajout au groupe ssh davidadmin:services:apt-dater [2020/04/26 00:13] (Version actuelle) klafyvel
Ligne 2: Ligne 2:
  
 Chaque serveur de FedeRez est configuré pour être mis à jour via [[http://www.ibh.de/apt-dater/|apt-dater]]. Chaque serveur de FedeRez est configuré pour être mis à jour via [[http://www.ibh.de/apt-dater/|apt-dater]].
 +======= Comment faire les mises à jour ? =======
  
-====== Infos générales ======+{{page>admin:services:apt-dater:controller:utilisation&nofooter}}
  
 +======= Installation sur les hosts =======
  
-===== Liens (potentiellement) utiles =====+{{page>admin:services:apt-dater:host&nofooter}}
  
-  * Site officiel http://www.ibh.de/apt-dater/ +{{page>admin:services:apt-dater:wrapper&nofooter}}
-  * Référence pour la config et la sécurisation d'apt-dater : https://sdeziel.info/apt-dater/index.html+
  
-===== En speed ====+======= Le contrôleur =======
  
-==== Ajouter une clef pour un admin sur une machine managée par apt-dater ====+{{page>admin:services:apt-dater:controller&nofooter}}
  
-Sur **chaque** machine(sconcernée(s) (en gros [[admin:serveurs:hexagon|hexagon]], [[admin:serveurs:quigon|quigon]] et [[admin:serveurs:baldrick|baldrick]]):+====== Liens (potentiellementutiles ======
  
-:!: Attention ici exemples de zertrin et David_5.1, adapter **les clefs et les IP autorisées** à votre cas ! +  Site officiel http://www.ibh.de/apt-dater/ 
- +  * Référence pour la config et la sécurisation d'apt-dater : https://sdeziel.info/apt-dater/index.html
-  # en tant que root +
-  cat << EOF >> ~aptdater/.ssh/authorized_keys +
-  no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc,no-X11-forwarding,from="127.0.0.0/8,91.121.177.109,2001:41d0:1:f26d::1" ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAACFBADNkXj0+teRl15r6PasiFBCSy4TPIzBQwpyR+DqDwkd4l6B23wY0A/psfZMoSPV6c2PxgOh7WKZMMrturZTR4wUBAACUHVxJCvroLwbaJvJNqVRBqUhNluWoNLSVpSIskoGOEf9E1dtAM24nZdqThBUFTnK7Ws2umPtiybncpUJOL/UPg== david@sinquin/ks51 +
-  no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc,no-X11-forwarding,from="127.0.0.0/8,91.121.136.69,2001:41d0:1:b745::1" ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO2O2dQgm7g2/M2Jg9xkSKhPqjHTK/Jx0pOIVP/CDSuv zertrin@gluon +
-  EOF +
- +
-==== Installer apt-dater sur une machine de management ==== +
- +
-Installation du paquet (exemple Debian, pour les autres distros, débrouillez vous !): +
- +
-  apt-get install apt-dater +
- +
-En tant qu'utilisateur normal, lancer une première fois ''apt-dater'' et quittez immédiatement. Cela aura pour effet de créer les fichiers de configuration d'apt-dater dans ''$XDG_CONFIG_HOME/apt-dater'' (c'est à dire en général ''~/.config/apt-dater''). +
- +
-Modifier ''~/.config/apt-dater/hosts.conf''+
- +
-Ajouter (ou remplacer l'entrée d'exemple ''IBH'' par) : +
- +
-  [FedeRez] +
-  Hosts=aptdater@hexagon.federez.net;aptdater@quigon.federez.net;aptdater@baldrick.federez.net; +
- +
-Relancer apt-dater, les serveurs seront dans la section ''Unknown''. Rafraichir les serveurs avec la commande ''g''. En cas de soucis, la commande ''e'' aide au diagnostic. +
- +
-====== Mise en place initiale d'apt-dater sur les machines managées ====== +
- +
-Notetoutes les étapes ci-dessous se font en tant que superutilisateur. +
-===== Installation ===== +
- +
-Installation du paquet : +
- +
-  apt-get install apt-dater-host +
- +
-===== Configuration initiale ===== +
- +
-La config suivie ici s'inspire très fortement de celle disponible sur https://sdeziel.info/apt-dater/index.html+
- +
-==== Ajout d'un utilisateur dédié ==== +
- +
-  adduser --quiet --system --home /var/lib/aptdater --group --shell /bin/sh aptdater +
-  adduser aptdater ssh +
- +
-==== Configuration de SSH pour apt-dater ==== +
- +
-On n'autorise que des connexions par clef depuis certaines IPs et on n'autorise que l'exécution d'un wrapper de sécurisation: +
- +
-  mkdir -m 0700 ~aptdater/.ssh +
- +
-Ajout de la clef d'un admin dans le authorized_keys d'aptdater: +
- +
-:!: Attention ici exemple de David_5.1, adapter la clef et les IP autorisées à votre cas ! +
- +
-  touch ~aptdater/.ssh/authorized_keys +
-  chown aptdater: -R ~aptdater/.ssh +
-  cat << EOF >> ~aptdater/.ssh/authorized_keys +
-  no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc,no-X11-forwarding,from="127.0.0.0/8,91.121.177.109,2001:41d0:1:f26d::1" ecdsa-sha2-nistp521 AAAAE2VjZHNhLXNoYTItbmlzdHA1MjEAAAAIbmlzdHA1MjEAAACFBADNkXj0+teRl15r6PasiFBCSy4TPIzBQwpyR+DqDwkd4l6B23wY0A/psfZMoSPV6c2PxgOh7WKZMMrturZTR4wUBAACUHVxJCvroLwbaJvJNqVRBqUhNluWoNLSVpSIskoGOEf9E1dtAM24nZdqThBUFTnK7Ws2umPtiybncpUJOL/UPg== david@sinquin/ks51 +
-  EOF +
- +
-==== Configuration de sudo pour apt-dater ==== +
- +
-  cat << "EOF" >> /etc/sudoers.d/apt-dater-host +
-  # package installation is denied +
-  aptdater ALL = (root) NOPASSWD: /usr/bin/apt-get update +
-  aptdater ALL = (root) NOPASSWD: /usr/bin/apt-get clean +
-  aptdater ALL = (root) NOPASSWD: /usr/bin/apt-get dist-upgrade +
-  aptdater ALL = (root) NOPASSWD: /usr/bin/apt-get --assume-yes dist-upgrade +
-  aptdater ALL = (root) NOPASSWD: /usr/bin/apt-get dist-upgrade --assume-yes +
-  aptdater ALL = (root) NOPASSWD: /usr/bin/apt-get --quiet --simulate --fix-broken --allow-unauthenticated dist-upgrade +
-  aptdater ALL = (root) NOPASSWD: /usr/bin/apt-get dist-upgrade --quiet --simulate --fix-broken --allow-unauthenticated +
-  aptdater ALL = (root) NOPASSWD: /usr/sbin/needrestart +
-  EOF +
- +
-  chmod 0440 /etc/sudoers.d/apt-dater-host +
- +
-==== Demande de validation des mise à jour ==== +
- +
-Pour qu'une demande de confirmation de la liste des paquets à mettre à jour soit faite, il faut modifier ''/etc/apt-dater-host.conf'' pour qu'il contienne ''ASSUMEYES=0;''+
-  sed -i 's/^$ASSUMEYES=1;$/$ASSUMEYES=0;/' /etc/apt-dater-host.conf +
-==== Limitation de la priorité d'apt-dater apt-dater (optionnel) ==== +
- +
-  printf "aptdater\t-\tpriority\t10\n" > /etc/security/limits.d/aptdater.conf +
- +
-==== Création d'un wrapper pour sécuriser apt-dater ==== +
- +
-À placer dans ''/usr/local/bin/apt-dater-host-wrapper'' +
- +
-<code bash> +
-#!/bin/sh +
- +
-set -e +
-set -u +
- +
-# Explicitly set the PATH to that of ENV_SUPATH in /etc/login.defs and unset +
-# various other variables. For details, see: +
-# https://wiki.ubuntu.com/SecurityTeam/AppArmorPolicyReview#Execute_rules +
-export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +
-export ENV= +
-export CDPATH= +
- +
-LOGGER="/usr/bin/logger" +
-APT_DATER_HOST="$(which apt-dater-host)" +
-KILL="/bin/kill" +
-SLEEP="/bin/sleep" +
- +
-# Install command allowed? +
-INSTALL_ALLOWED="false" +
-if [ "$#" -eq 1 ]; then +
-  if [ "$1" = "--install-allowed" ]; then +
-    INSTALL_ALLOWED="true" +
-  fi +
-fi +
- +
-illegal_command() { +
-  # Do not log SSH_ORIGINAL_COMMAND for security reasons +
-  $LOGGER "$(basename $0) illegal command denied" +
-  # Default deny +
-  $KILL -9 $PPID +
-  exit 0 +
-+
- +
-check_ssh_command() { +
-  if [ "$#" -lt 2 ]; then +
-    # not in the form of apt-dater-host upgrade +
-    illegal_command +
-  fi +
- +
-  if [ "$1" != "apt-dater-host" ]; then +
-    # not invoking apt-dater-host +
-    illegal_command +
-  else +
-    # Remove the 1st arg with later replace it with the +
-    # fully qualified path to apt-dater-host +
-    shift +
-  fi +
- +
-  COMMAND="$1" +
-  shift +
- +
-  if [ "$COMMAND" = "refresh" -o "$COMMAND" = "kernel" ]; then +
-    $APT_DATER_HOST $COMMAND +
-  elif [ "$COMMAND" = "upgrade" ]; then +
-    # Don't kill the shell session right away when +
-    # upgrading/installing to please apt-dater +
-    $APT_DATER_HOST $COMMAND && $SLEEP 0.5 +
-  elif [ "$COMMAND" = "install" ]; then +
-    if [ "$INSTALL_ALLOWED" = "true" ]; then +
-      # Don't kill the shell session right away when +
-      # upgrading/installing to please apt-dater +
-      $APT_DATER_HOST $COMMAND $* && $SLEEP 0.5 +
-    else +
-      illegal_command +
-    fi +
-  fi +
-+
- +
-if [ -z "$SSH_ORIGINAL_COMMAND" ]; then +
-  illegal_command +
-fi +
- +
-case "$SSH_ORIGINAL_COMMAND" in +
-  *\&*) +
-    illegal_command +
-    ;; +
-  *\(*) +
-    illegal_command +
-    ;; +
-  *\{*) +
-    illegal_command +
-    ;; +
-  *\;*) +
-    illegal_command +
-    ;; +
-  *\>*) +
-    illegal_command +
-    ;; +
-  *\`*) +
-    illegal_command +
-    ;; +
-  *\|*) +
-    illegal_command +
-    ;; +
-  apt-dater-host\ refresh) +
-    check_ssh_command $SSH_ORIGINAL_COMMAND +
-    ;; +
-  apt-dater-host\ upgrade) +
-    check_ssh_command $SSH_ORIGINAL_COMMAND +
-    ;; +
-  apt-dater-host\ install\ *) +
-    check_ssh_command $SSH_ORIGINAL_COMMAND +
-    ;; +
-  apt-dater-host\ kernel) +
-    check_ssh_command $SSH_ORIGINAL_COMMAND +
-    ;; +
-  *) +
-    illegal_command +
-    ;; +
-esac +
-</code> +
- +
-En oubliant pas de le rendre exécutable:+
  
-  chmod 0755 /usr/local/bin/apt-dater-host-wrapper 
  
admin/services/apt-dater.1512172485.txt.gz · Dernière modification : 2017/12/02 00:54 de david

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki