Administration von Unix-Rechnern mit cfengine


 

Erfahrungen und Probleme

Sysadmin-Organisation

  • Administrationsdomänen (verteilte kooperative Sysadmin)

  •  
    • vertikale Administrationsdomäne: Root-Admin für alle Hosts einer BS-Plattform
    • horizontale Administrationsdomänen: Spezialisten sind für spezielle Problembereiche auf allen BS-Plattformen verantwortlich
    • Für korrekte Konfiguration eines Hosts ist Root-Admin allein verantwortlich
    • bei speziellen Problemen in einer horizontale Administrationsdomäne auf einem Host: Root-Admin stellt Anforderung an betreffenden Spezialisten
    • Modifikation von Host-Konfigurationsfiles (nach der Installation) nur über Master-Konfigurationsfiles
    • Admin-Aktionen werden mittels priv und dem normalen Nutzer-Account realisiert
  • Überblick über priv

  •  
    • differenzierte und flexible Zugriffsteuerung auf Basis
      • des Nutzer-Accounts,
      • der Mitgliedschaft von group oder netgroup,
      • dem Typ des Host oder
      • des Betriebssystems
    • Steuerung der Kommandozeilen-Argumente
    • SUID-Wrapper plus Policy-Database
    • alle Aktionen werden protokolliert
    • Beispiel:  /etc/priv_policy für Klasse PC_Pool
 
rpm     :passwd: \ 
        :login=wmc,tla: \ 
        :argv=/bin/rpm,$*: 
cfengine :passwd: \ 
        :login=wmc,tla,meh,thm,ghe: \ 
        :argv=/uni/global/bin/cfengine,$*: 
glint   :passwd: \ 
        :login=wmc,tla: \ 
        :argv=/usr/bin/glint,$*: 
kill    :login=thm,meh,czi,wmc,dgr,ghe,stb,tla,bmu,gha,cho,imu,anhe: \ 
        :passwd: \ 
        :argv=/bin/kill,$*: 
reboot  :passwd: \ 
       
:login=thm,meh,czi,wmc,dgr,ghe,stb,tla,bmu,gha,cho,imu,anhe
\ 
        :argv=/sbin/reboot: 
halt    :passwd: \ 
       
:login=thm,meh,czi,wmc,dgr,ghe,stb,tla,bmu,gha,cho,imu,anhe
\ 
        :argv=/sbin/halt: 
rrpm    :login=wmc,tla: \ 
        :argv=/bin/rpm,$*: 
rcfengine    :login=wmc,tla: \ 
        :argv=/uni/global/bin/cfengine,$*:
 
  •  
     
  • Administration von /etc/priv_policy mit cfengine
  • Aufbau des Prototyp-Files im AFS (PRIVPOLICY)
  • Installation des Mechanismus auf dem Host mittels cfengine
 
 
echo " priv_policy installieren ..." 
cd /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS 
echo -n "Bitte AFS-Nutzerkennzeichen eingeben: " 
read NKZ 
if ! /usr/afsws/bin/klog $NKZ; then 
        echo "Abbruch!" 
        exit 1 
fi 

cfengine  -q  -v -DPRIV -f cfengine.spec.conf >&/tmp/cfengine.spec.conf.PRIV.$$ 
 

 
 
  • cfengine.spec.conf
 
 
### 
# cfengine.spec.conf 
# cfengine special configuration for RedHat Linux, URZ TU Chemnitz 
# 25.02.98 wmc 
### 

# BEGIN cfengine.spec.conf 

import: 

  any:: 

    # 
    # Files for all Linux Systems 
    # 
    cf.linux_Classes 
    cf.linux_spec_Main 

  # 
  # Files for special action classes 
  # Call: cfengine -D<action class> -f cfengine.spec.conf 
  # 
  MOTD::           cf.linux_Motd 
  PWDORIG::        cf.linux_Edit_Orig_Passwd 
  PWDLOKAL::       cf.linux_Edit_Local_Passwd 
  PRIV::           cf.linux_PrivPolicy 
  RPM_INFO::       cf.linux_RpmInfo 
  RPM_UPGR::       cf.linux_RpmUpgrade 
  AFSCRON::        cf.linux_Afs_Cron 
  PWDMERGE::       cf.linux_PWDMERGE 

# END cfengine.spec.conf 
 

 
 
  • cf.linux_PrivPolicy
 
### 
# cf.linux_PrivPolicy 
# cfengine configuration for RedHat Linux, URZ TU Chemnitz 
# 03.02.98 wmc 
### 

# BEGIN cf.linux_PrivPolicy 

copy: 

 PhilPriv.privupd:: 
   $(PRIVDIR)/$(host)         dest=/etc/ rec=inf type=checksum def=PRIVUPD 

 Mb3Priv.privupd:: 
   $(PRIVDIR)/$(host)         dest=/etc/ rec=inf type=checksum def=PRIVUPD 

 PhysikPool.privupd:: 
   $(PRIVDIR)/PhysikPool      dest=/etc/ rec=inf type=checksum def=PRIVUPD 

 .... 

  CanServer.privupd:: 
   $(PRIVDIR)/CanServer       dest=/etc/ rec=inf type=checksum def=PRIVUPD 

 DbServer.privupd:: 
   $(PRIVDIR)/DbServer        dest=/etc/ rec=inf type=checksum def=PRIVUPD 

 tech7.privupd:: 
   $(PRIVDIR)/tech7       dest=/etc/ rec=inf type=checksum def=PRIVUPD 

################# 
files: 

 any.privupd:: 
   /etc/priv_policy                     m=600 o=root g=root act=fixplain 
   /etc/priv_policy.db                  m=600 o=root g=root act=fixplain 
 

################# 
shellcommands: 
 PRIVUPD.privupd:: 
  "/usr/local/bin/makedb.ksh /etc/priv_policy /etc/priv_policy" 
 

# END cf.linux_PrivPolicy

 
 
  • System-Sicherheit gefährdet: Zugriffsrechte für Verzeichnis PRIVPOLICY !!
  • Aktualisieren  über  turnusmäßigen cfengine-Aufruf (z.B. täglich über cron)

Aufruf der cfengine-Scripts

  • nach der Installation des Systems (kommt später)
  • während des Boot-Vorgangs

  •  
    • File root4Allsystems/etc/rc.d/init.d/cf.startup wird beim Booten nach Netzinitialisierung und afs-Start ausgeführt:
 
#!/bin/sh 
################################################ 
# ACHTUNG! Aenderungen in diesem File sind zwecklos, da es von 
# cfengine gewartet wird 
# wmc, 06.05.97 
################################################ 

# Wenn AFS verfuegbar, wird cfengine bei jedem Boot ausgefuehrt (Normalfall) 
# cfengine kann nicht gerufen werden, wenn ein spezieller Kern (Label *.noafs)  
# geladen wurde 
# wmc 11.09.97 
 
# Protokollierung ins AFS ueber afs_cron 
# wmc 20.02.98 

# Test, ob AFS gestartet werden soll/sollte/kann/konnte 
if grep ".noafs" /proc/cmdline; then 
   # Kern Label: *.noafs 
   echo " No cfengine startup check !" 
   exit 1 
fi 

# es kann zu diesem Zeitpunkt kein cfengine laufen! 
/bin/rm -f /etc/cfengine.pid >& /dev/null 
 

if [ -x /afs/.tucz/admin/linux/REDHAT/CFENGINE/NSCRIPTS/startup_check.sh ]; then 
        echo "cfengine startup check." #>/dev/console 
        /usr/sbin/afs_cron /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS/startup_check.sh& 
fi

 
 
  • File startup_check.sh
 
# !/bin/sh 
# Startup-Check fuer RedHat-Linux-Syteme durch cfengine 
# Laeuft bei jedem Booten nach Netz- und AFS-Initialisierung 
# 06.05.97 wmc 
# 12.08.97 wmc (mail to root) 
# 20.02.98 wmc (Umstellung auf neue cfengine-"Technologie") 

HOST=`hostname -s` 
MAILTO=root 
export CFINPUTS=/afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS 
export PATH=/usr/X11R6/bin:/usr/local/bin:/uni/dept/bin:/usr/afsws/bin:/bin:/usr/bin:/usr/sbin:/uni/global/bin:/usr/afsws/etc 

LOG_DIR=/afs/.tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/LOGS 

exec >> ${LOG_DIR}/${HOST}/cfengine_startup_check.log 2>> ${LOG_DIR}/${HOST}/cfengine_startup_check.log 

echo "===`date`===$*===BEGIN===" 2>&1 

cat /etc/issue >${LOG_DIR}/${HOST}/ISSUE 
dmesg > ${LOG_DIR}/${HOST}/DMESG 

cfengine -q --no-lock --inform -DHourly -DMOTD -NStaroffice 

if [ $? -ne 0 ] 
then 
   mail -s "$HOST: CFENGINE-Problem (startup_check.sh)" $MAILTO </dev/null >/dev/null 
fi 
echo "===`date`===$*===END=====" 2>&1

 
  • regelmäßig per cron

  •  
    • root4Allsystems/etc/cron.cfengine/cfengine.hourly
 
$ cat  root4Allsystems/etc/cron.cfengine/cfengine.hourly  
/usr/sbin/afs_cron /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS/cf.cron_hourly.sh 

$ cat /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS/cf.cron_hourly.sh 
#!/bin/sh 
# cfengine check for RedHat Linux systems over crond  
# should run in short terms (hourly) 
# 09.02.98 wmc 

HOST=`hostname -s` 
MAILTO=root 

export CFINPUTS=/afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS 
export PATH=/usr/X11R6/bin:/usr/local/bin:/uni/dept/bin:/usr/afsws/bin:/bin:/usr/bin:/usr/sbin:/uni/global/bin:/usr/afsws/etc 

/usr/afsws/bin/fs flushv /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/LOGS 
/usr/afsws/bin/fs flushv /afs/tu-chemnitz.de/admin/linux 

# wait 1...255 seconds depending on ip-adr 
sh $CFINPUTS/sleep.sh 

LOG_DIR=/afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/LOGS 
exec >> ${LOG_DIR}/${HOST}/cf.cron_hourly.sh.log 2>> ${LOG_DIR}/${HOST}/cf.cron_hourly.sh.log 

echo "===`date`===$*===BEGIN===" 2>&1 

# Hourly --> all actions, which should done hourly 
cfengine  --no-lock --inform -DHourly -DMOTD -NStaroffice  

if [ $? -ne 0 ] 
then 
   mail -s "$HOST: CFENGINE-Problem (cf.cron_hourly.sh)" $MAILTO </dev/null >/dev/null 
fi 
echo "===`date`===$*===END=====" 2>&1

 
  • root4Allsystems/etc/cron.daily/cfengine.daily
 
$ cat root4Allsystems/etc/cron.daily/cfengine.daily 
/usr/sbin/afs_cron /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS/cf.cron_daily.sh 

$  cat /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS/cf.cron_daily.sh 
#!/bin/sh 
# cfengine check for RedHat Linux systems over crond  
# should run daily 
# 09.02.98 wmc 

HOST=`hostname -s` 
MAILTO=root 

export CFINPUTS=/afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS 
export PATH=/usr/X11R6/bin:/usr/local/bin:/uni/dept/bin:/usr/afsws/bin:/bin:/usr/bin:/usr/sbin:/uni/global/bin:/usr/afsws/etc 

# wait 1...255 seconds depending on ip-adr 
sh $CFINPUTS/sleep.sh 

LOG_DIR=/afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/LOGS 
exec >> ${LOG_DIR}/${HOST}/cf.cron_daily.sh.log 2>> ${LOG_DIR}/${HOST}/cf.cron_daily.sh.log 

echo "===`date`===$*===BEGIN===" 2>&1 

cat /etc/issue >${LOG_DIR}/${HOST}/ISSUE 

# Daily --> all actions, which should done daily (nightly) 
# RPM_INFO --> check what rpm packages should be updatet (but don't update!) 
# MOTD --> update message of to day 
cfengine --no-lock --inform -DDaily -DRPM_INFO -DMOTD -NStaroffice 

cfengine --inform -DPRIV -f cfengine.spec.conf 

if [ $? -ne 0 ]  
then 
   mail -s "$HOST: CFENGINE-Problem (cf.cron_daily.sh)" $MAILTO </dev/null >/dev/null 
fi 
echo "===`date`===$*===END=====" 2>&1 

/bin/rpm -qa >${LOG_DIR}/${HOST}/rpm_qa.log 
/bin/rpm -qa | sort >${LOG_DIR}/${HOST}/rpm_qa_sort.log 
/bin/rpm -qa --queryformat "%10{size} %20{name} %{group}\n"|sort -nr > ${LOG_DIR}/${HOST}/RPM_PAKETE

 
  • analog
  • weekly bzw.  monthly
 
  • Aufruf von cfengine bei Bedarf "on the fly" durch Script  root4Allsystems/usr/local/bin/sys_update:
 
$ cat   root4Allsystems/usr/local/bin/sys_update 
#!/bin/sh 
# 
# /usr/local/bin/sys_update: 
# 
# Das Script kann von allen in der priv-Datenbasis (/etc/priv_policy) 
# autorisierten Nutzern benutzt werden, 
# um Aenderungen im cfengine-Repository eines Hosts 
# (/afs/tucz/admin/linux/REDHAT/CFENGINE/*) 
# in das root-Filesystems des betreffenden Hosts zu uebertragen 
# Es wird das NIS-Passwort des Aufrufers abgefragt (falls der Aufruf 
# nicht in den letzen 5 Minuten bereits erfolgte) 
# Die Protokollierung der cfengine-Aktionen erfolgt in 
# /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/LOGS/<hostname>/linux_conf_sys_update.$LOGNAME 
# d.h. fuer jeden (autorisierten) Nutzer wird ein Logfile fuer diesen Host 
# (fort)geschrieben 
 
# 07.08.97 wmc 

/afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS/cf.linux_sys_update.sh 
 

$  cat /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS/cf.linux_sys_update.sh 
#!/bin/sh 
# cfengine sys_update for RedHat Linux systems  
# should run after changes of configuration data  
# 20.02.98 wmc 

HOST=`hostname -s` 
MAILTO=root 

export CFINPUTS=/afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS 
export PATH=/usr/X11R6/bin:/usr/local/bin:/uni/dept/bin:/usr/afsws/bin:/bin:/usr/bin:/usr/sbin:/uni/global/bin:/usr/afsws/etc 

LOG_DIR=/afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/LOGS/ 
LOG_FILE=${LOG_DIR}/${HOST}/linux_conf_sys_update.$LOGNAME.log 

echo "===`date`===$*===BEGIN===" $2>&1 >> $LOG_FILE 

cat /etc/issue >${LOG_DIR}/${HOST}/ISSUE 
# Daily --> all actions, which should done daily (nightly) 
priv cfengine --no-lock --inform -DDaily -NStaroffice -NStaroffice40  $2>&1 >> $LOG_FILE 

if [ $? -ne 0 ] 
then 
   mail -s "$HOST: CFENGINE-Problem (cf.linux_sys_update.sh)" $MAILTO </dev/null >/dev/null 
fi 
echo "===`date`===$*===END=====" 2>&1  >> $LOG_FILE

 

Einbeziehen eines neuen Systems <hostname>

  • Fall 1: es gibt bereits Systeme mit gleichem Einsatzzweck (gleicher Funktion), d.h.  es existieren  "passende" Klassen bzgl. Funktionalität und Eigenschaften

  •  
    • im File cf.linux_Classes Klasse <hostname> an entsprechenden Stellen hinzufügen
    • Source-Root für Klasse <hostname> aufbauen (Verzeichnisstruktur <hostname>, z.B. Script make_source_root_host)
    • (evtl.) priv_policy einrichten
    • Systeminstallation
    • Ausführung von Post-Install-Scripts, um notwendige Voraussetzungen zu schaffen
    • evtl. spezielle SW-Installationen: ssh_host_key, priv_policy, Printer-Installation, afs_cron, StarOffice,... (siehe unten)
    • neu Booten
    • Host-spezifische Konfigurationsfiles und Infos nach Source-Root für Klasse <hostname> speichern (z.B. Script host_info)
    • Beispiel für Post-Install-Scripts
     
    # cd /afs/tucz/admin/linux/REDHAT/CFENGINE/NSCRIPTS 
    # cat host_inst_part_one 
    #!/bin/sh 
    export CFINPUTS=/afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS 
    export PATH=/usr/X11R6/bin:/usr/local/bin:/uni/dept/bin:/usr/afsws/bin:/bin:/usr/bin:/usr/sbin:/uni/global/bin:/usr/afsws/etc 
    CF_PATH=/afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/ROOTS/root4RH51/usr/local/bin 

    echo "rmdir /var/spool/mail" 
    rmdir  /var/spool/mail 
    echo "mkdir /usr/local/opt" 
    cp -p -d -r /opt /usr/local >&/dev/null 
    /bin/rm -rf /opt >&/dev/null 
    mkdir /usr/local/opt >&/dev/null 
    echo "ln -s /usr/local/opt /opt" 
    ln -s /usr/local/opt /opt 

    # nur fuer PhysikPool !!!!!! 
    rm /etc/rc.d/rc3.d/S72amd 

    # 3.6.97 muss auf allen Kisten einmal laufen 
    echo "rmdir /mnt/floppy" 
    /bin/rmdir /mnt/floppy >&/dev/null 

    echo "cfengine.conf (-DDaily) (1)" 
    cd /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS 
    $CF_PATH/cfengine -q -v -DDaily >&/tmp/cf.linux_conf_allgemein.1.$$ 

    echo "cfengine.conf (-DDaily) (2)" 
    $CF_PATH/cfengine -q -v -DDaily >&/tmp/cf.linux_conf_allgemein.2.$$ 

    echo "cfengine.spec.conf (PWDORIG)" 
    $CF_PATH/cfengine -v -q -DPWDORIG -f cfengine.spec.conf >&/tmp/cfengine.spec.conf.PWDORIG.$$ 

    echo "cf.conf_edit_lokal_passwd" 
    $CF_PATH/cfengine -v -q -DPWDLOKAL -f cfengine.spec.conf >&/tmp/cfengine.spec.conf.PWDLOKAL.$$ 

    ... 

    # cat host_inst_part_two  
    #!/bin/sh 
    export CFINPUTS=/afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS 
    export PATH=/usr/X11R6/bin:/usr/local/bin:/uni/dept/bin:/usr/afsws/bin:/bin:/usr/bin:/usr/sbin:/uni/global/bin:/usr/afsws/etc 

    cd /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS 
    echo " ssh installieren ..." 
    ./ssh_install 

    #cd /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS 
    #echo " ssh re-installieren ..." 
    #./ssh_host_key_re_install 

    echo " priv_policy installieren ..." 
    cd /afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/NSCRIPTS 
    echo -n "Bitte AFS-Nutzerkennzeichen eingeben: " 
    read NKZ 
    if ! /usr/afsws/bin/klog $NKZ; then 
            echo "Abbruch!" 
            exit 1 
    fi 

    cfengine  -q  -v -DPRIV -f cfengine.spec.conf >&/tmp/cfengine.spec.conf.PRIV.$$ 

    echo " afs_cron installieren ..." 
    cfengine  -q  -v -DAFSCRON -f cfengine.spec.conf >&/tmp/cfengine.spec.conf.AFSCRON.$$ 

    #echo " staroffice installieren ..." 
    #./star_inst 

    echo " kde, autorpm und ctwm installieren ..." 
    rpm -Uvh /afs/.tu-chemnitz.de/global/linux2/install/redhat-5.1/i386/RedHat/RPMS/kde* 
    rpm -Uvh /afs/.tu-chemnitz.de/global/linux2/install/redhat-5.1/i386/RedHat/RPMS/autorpm-*.i386.rpm 
    rpm -Uvh /afs/.tu-chemnitz.de/global/linux2/install/redhat-5.1/i386/RedHat/RPMS/ctwm-*.i386.rpm 
    rpm -Uvh /afs/.tu-chemnitz.de/global/linux2/install/redhat-5.1/i386/RedHat/RPMS/xsession*.i386.rpm 
    rpm -Uvh /afs/.tu-chemnitz.de/global/linux2/install/redhat-5.1/i386/RedHat/RPMS/ncurses3*.i386.rpm 
    #rpm -Uvh /afs/.tu-chemnitz.de/global/linux2/install/redhat-5.1/i386/RedHat/RPMS/sndconfig-0.21-2.i386.rpm 

    echo "rm /etc/cron.daily/autorpm" 
    /bin/rm /etc/cron.daily/autorpm 

    sh /etc/cron.daily/updatedb.cron 

    echo "jetzt pruefen: /etc/ssh*, /etc/.afs_cron, /etc/priv_policy ..." 
    echo "falls O.K. --> reboot" 
    vi /usr/vice/etc/cacheinfo 
    ls -l /etc/priv* /etc/ssh* /var/spool/printers/ /etc/.afs* 
    date 
    echo -n "Soundkartentest - <ENTER> " 
    read abc 
    /sbin/pnpdump | grep "# ANSI string" 
    if [ $? = 0 ];then 
            echo "Rechner hat eine Soundkarte - evtl. bezueglich Kern beachten !!!" 
            echo "<ENTER> :" 
            read abcd 
            rpm -Uvh /afs/.tu-chemnitz.de/global/linux2/install/redhat-5.1/i386/RedHat/RPMS/sndconfig-0.21-2.i386.rpm 
            /usr/sbin/sndconfig 
    fi 
    /sbin/pnpdump | grep "# No boards found" 
    if [ $? = 0 ];then  
            echo "Rechner hat keine Soundkarte - Kern unproblematisch." 
            echo 
    fi

     
     
  • Fall 2: Systeme mit gleicher Funktionalität und/oder Eigenschaften nicht vorhanden, d.h. es existieren noch keine "passenden" Klassen
  • im File cf.linux_Classes Klasse <hostname> an entsprechenden Stellen hinzufügen
  • zusätzlich
  • geeignete Klassen bzgl. Funktionalität und Eigenschaften entwerfen und in cf.linux_Classes einfügen
  • Source-Root für Klasse <hostname> aufbauen (Verzeichnisstruktur <hostname>, z.B. Script make_source_root_host)
  • Source-Root für die neu definierten Klassen aufbauen


  • (evtl.) priv_policy einrichten
  • Systeminstallation usw.
  • Fall 3: System gehört zu einer noch nicht vorhandenen Administrationsdomäne (DOM_xxx)

  •  
    • neue Admin-Domäne (entsprechend der Anforderungen und Bedingungen) definieren (einschließlich Scripts und Verzeichnishierarchie)
    • weiter analog Fall 2

Spezielle Probleme

  • Drucker-Installation: printer_install [-s <standard_drucker>] <druckername>...<directory>
  • ssh-Konfiguration (Script ssh_install)
 
#!/usr/afsws/bin/pagsh 
# Secure-Shell: (erst nach AFS-Install) 

 
HOST=`hostname -s` 
CF=/afs/tu-chemnitz.de/admin/linux/REDHAT/CFENGINE/ROOTS 

echo -n "Bitte AFS-Nutzerkennzeichen eingeben: " 
read NKZ 
if ! /usr/afsws/bin/klog $NKZ; then 
        echo "Abbruch!" 
        exit 1 
fi 

# Existierte fuer den Host bereits ssh_host_key? 
if [ -f ${CF}/$HOST/etc/ssh_host_key.des ]; then 
        echo "${CF}/$HOST/etc/ssh_host_key.des existiert bereits!" 
        echo "ssh_host_key muss fuer $HOST reinstalliert werden (ssh_host_key_re_install)!" 
        exit 1 
fi 

# Erzeugen des Host Keys (/etc/ssh_host_key und /etc/ssh_host_key.pub) 
if [ ! -f /etc/ssh_host_key ]; then 
  /uni/global/bin/ssh-keygen -b 1024 -f /etc/ssh_host_key -N '' 
  chown root.root /etc/ssh_host_key 
  chown root.root /etc/ssh_host_key.pub 
  chmod 0400 /etc/ssh_host_key 
  chmod 0444 /etc/ssh_host_key.pub 

# Public Key an thm schicken! -- der steht auch in /etc/ssh_host_key.pub 
  mail -s "Public Hostkey $HOST" thm,wmc </etc/ssh_host_key.pub 
fi 
# Sichern des /etc/ssh_host_key  
if [ -f /etc/ssh_host_key -a -r /afs/tu-chemnitz.de/admin/linux/SK/kfssh_lx_hsts ]; then 
  /uni/global/bin/des -E -k `cat /afs/tu-chemnitz.de/admin/linux/SK/kfssh_lx_hsts` < /etc/ssh_host_key > ${CF}/$HOST/etc/ssh_host_key.des 
fi 
# Sichern des /etc/ssh_host_key.pub 
if [ -r /etc/ssh_host_key.pub ]; then 
  cp -p /etc/ssh_host_key.pub  ${CF}/$HOST/etc/ssh_host_key.pub 
fi

 
  • analog: ein System soll komplett neu installiert werden , aber seinen private host key behalten --> (Script ssh_host_key_re_install)
  • Problem: einheitlich Einträge  für bestimmte Accounts in /etc/passwd (z.B. nobody, not)

  •  
    • Original-Passwortfile korrigieren
     
    # cfengine -v -q -DPWDORIG -f cfengine.spec.conf >&/tmp/cfengine.spec.conf.PWDORIG.$$ 

    ... -->   cf.linux_Edit_Orig_Passwd 

    # cat cf.linux_Edit_Orig_Passwd 
    ### 
    # cf.linux_Edit_Orig_Passwd 
    # cfengine configuration for RedHat Linux, URZ TU Chemnitz 
    # 05.02.98 wmc 
    ### 

    # BEGIN cf.linux_Edit_Orig_Passwd 

    #   Korrigiere Original(!)-Passwordfile 
    #################################### 
    #root:?????:0:0:root:/root:/bin/bash 
    #bin:*:1:1:bin:/bin: 
    #daemon:*:2:2:daemon:/sbin: 
    #adm:*:3:4:adm:/var/adm: 
    #lp:*:4:7:lp:/var/spool/lpd: 
    #sync:*:5:0:sync:/sbin:/bin/sync 
    #shutdown:*:6:0:shutdown:/sbin:/sbin/shutdown 
    #halt:*:7:0:halt:/sbin:/sbin/halt 
    #mail:*:8:12:mail:/var/spool/mail: 
    #news:*:9:13:news:/var/spool/news: 
    #uucp:*:10:14:uucp:/var/spool/uucp: 
    #operator:*:11:0:operator:/root: 
    #games:*:12:100:games:/usr/games: 
    #gopher:*:13:30:gopher:/usr/lib/gopher-data: 
    #ftp:*:14:50:FTP User:/home/ftp: 
    #nobody:*:99:99:Nobody:/: 
    ##################################### 
    #   wmc 03.12.97 

    editfiles: 

     SambaServer:: 

      { /etc/passwd 

       LocateLineMatching "nobody:\*:99:99:Nobody:/:" 

       IncrementPointer "1" 

       BeginGroupIfNoMatch "not:r85QWWwgIiu72:99:10:reserved:/home/not:/bin/bash" 
         InsertLine "not:r85QWWwgIiu72:99:10:reserved:/home/not:/bin/bash" 
         InsertLine "netz:2BTtut3OrhEQk:97:10:Netz-Admin:/home/netz:/bin/bash" 
       EndGroup 
      } 

    ... 

     UrzPriv|PC_Pool_ADM:: 

      { /etc/passwd 

       LocateLineMatching "nobody:\*:99:99:Nobody:/:" 

       IncrementPointer "1" 

       BeginGroupIfNoMatch "not:r85QWWwgIiu72:99:10:reserved:/home/not:/bin/bash" 
         InsertLine "not:r85QWWwgIiu72:99:10:reserved:/home/not:/bin/bash" 
         InsertLine "+@urz_mitarbeiter::65535:65535:::" 
         InsertLine "+::65535:65535:::/uni/global/etc/nouserid" 
       EndGroup 
      } 

    ... 

    # END cf.linux_Edit_Orig_Passwd

     
     
    # cfengine -v -q -DPWDLOKAL -f cfengine.spec.conf >&/tmp/cfengine.spec.conf.PWDLOKAL.$$ 

    ... -->  cf.linux_Edit_Local_Passwd 

    # cat cf.linux_Edit_Local_Passwd 
    ### 
    # cf.linux_Edit_Local_Passwd 
    # cfengine configuration for RedHat Linux, URZ TU Chemnitz 
    # 05.02.98 wmc 
    ### 

    # BEGIN cf.linux_Edit_Local_Passwd 

    editfiles: 

     any.!SambaServer:: 

      { /etc/passwd 

        SplitOn ":" 

        ForEachLineIn "lokale_passwd_eintraege" 
          ReplaceLinesMatchingField "1" 
        EndLoop 

      } 

     SambaServer:: 

      { /etc/passwd 

        SplitOn ":" 

        ForEachLineIn "lokale_passwd_eintraege.samba_server" 
          ReplaceLinesMatchingField "1" 
        EndLoop 

      } 

    # END cf.linux_Edit_Local_Passwd 

    ... File lokale_passwd_eintraege 

    # cat lokale_passwd_eintraege 
    nobody:*:65535:65535:Nobody:/: 
    not:r85QWWwgIiu72:99:10:reserved:/home/not:/bin/bash 
     

     


28. November 1997, überarbeitet am 03.12.1998
Matthias Clauß, TU Chemnitz, URZ