OPSI/Installation

Aus Vosp.info
Wechseln zu:Navigation, Suche

Zurück zu OPSI
Dieses HowTo ist obsolet und wird nicht mehr gepflegt.
Die neuste Version ist Debian-OPSI-samba4
Oder einfach in OPSI rumstöbern.

Ziel

Am Ende der Installation wird ein Host mit folgenen Funktionen zur Verfügung stehen.

Primär

  • OPSI-Server ohne mysql
  • PrimaryDomainController (PDC im NT4 Style)
  • dhcp-Server
  • name-Server
  • Router für das OPSI-Netzwerk


Sekundär

  • openvpn
  • Backup wichtiger Userdaten
  • Squid für Black- & Withelisting

Eckdaten

  • Hostname: opsi-1-lnx01
  • Netzwerkname: opsi-1.local
  • Domain-Name: opsi-1
  • IP zum OPSI-Netzwerk: 10.8.190.1 (optional zusätzlich 10.8.190.10)

Namenskonventionen in AD für Computer, Domänen, Standorte und Organisationseinheiten

Starten mit Livesystem

Rechner mit GRML vom USB-Stick starten

Das Live-System grml bietet mit grml-debootstrap mehr Komfort als das Debian-debotstrap.
grml-debootstrap

Speicher vorbereiten

Festplatten automatisch partitionierern

[1]

sfdisk /dev/sda < my.layout

Nur ein Beispiel
my.layout


# partition table of /dev/sda
unit: sectors

/dev/sda1 : start=     2048, size=   497664, Id=83, bootable
/dev/sda2 : start=   501758, size=1953021954, Id= 5
/dev/sda3 : start=        0, size=        0, Id= 0
/dev/sda4 : start=        0, size=        0, Id= 0
/dev/sda5 : start=   501760, size=1953021952, Id=8e


RAID 1 erzeugen (mirror)

mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2 /dev/sda1 /dev/sdb1

LVM erzeugen

Physical Volume erzeugen.

pvcreate /dev/md0

Wir erzeugen die Volumegroup opsi_system. Diese besteht aus einem physical volume.

vgcreate opsi_system /dev/md0

Danach zwei logical volumes, eins für / und eins für /local

lvcreate -L 20G -n lv_root opsi_system
lvcreate -L 50G -n lv_local opsi_system

-L Größe des Volumes. G für Gigabyte
-n = Name des Volumes

mkfs.ext4 /dev/opsi_system/lv_root
mkfs.ext4 /dev/opsi_system/lv_local

Grundsystem installieren

grml-debootstrap --target /dev/opsi_system/lv_root --grub /dev/sda

grub2 auch auf /dev/sdb installieren

Dafür brauchen wir ein chroot in das neue System.

  • /dev/opsi_system/lv_root auf /mnt mounten


mount -t proc none /mnt/proc
mount -o bind /dev /mnt/dev
mount -t sysfs sys /mnt/sys
mount —bind /run /mnt/run
chroot /mnt /bin/bash

In der Chroot-Umgebung ausführen

grub-install --recheck --no-floppy/dev/sdb

Chroot verlassen

exit

Erststart des Systems

  • USB Stick <Bootmedium> entfernen.
reboot

Keyboard layout einstellen

dpkg-reconfigure console-data

Im ncurses-Menu auswählen.

  • Select keymap from arch list => O.K.
  • qwertz => O.K.
  • German => O.K.
  • Standard => O.K.
  • latin1 => O.K.

Sprache einstellen

dpkg-reconfigure locales

de_DE.UTF-8 auswählen und als default einstellen

Host bequem machen

Bash-completion

apt-get install bash-completion

Farbiges Promt

vim ~/.bashrc

export PS1='\[\033[0;31m\]\u\[\033[0;36m\]@\h:\[\033[0m\]\w\$ '
  • [0;36m] Türkis (cyan)
  • [0;32m] Grün (green)
  • [0;31m] Rot (red)
  • Meine Farbregeln
    • Vor dem Promt: rot für root und grün für user.
    • Hinter dem Promt: rot für Produktivserver, türkis für Testrechner und grün für Privatrechner/Workstations.


Meine .bashrc für root auf einem Testrechner.

# ~/.bashrc: executed by bash(1) for non-login shells.

export PS1='\[\033[0;31m\]\u\[\033[0;36m\]@\h:\[\033[0m\]\w\$ '
export LS_OPTIONS='--color=auto'
eval "`dircolors`"
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'

# Some more alias to avoid making mistakes:
alias rm='rm -i'
# bash-completion
. /etc/bash_completion

Host vorbereiten

Hostname

Wir nennen diesen Rechner opsi-1-lnx01

vim /etc/hostname

opsi-1-lnx01 eintragen

/etc/network/interfaces

Die interfaces Datei anpassen.

vim /etc/network/interfaces

eth0 ist hier das Interface zum OPSI-Netzwerk

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eth1
iface eth1 inet dhcp

auto eth0
iface eth0 inet static
       address 10.8.190.1
       broadcast 10.8.190.255
       netmask 255.255.255.0


Hosts Datei

Der Name wird mit der IP verknüpft, die die Verbindung zum OPSI-Netzwerk bereitstellt.

vim /etc/hosts

Folgene Zeile einfügen (entsprechend Installation#Eckdaten)

10.8.190.1 opsi-1-lnx01.opsi-1.local opsi-1-lnx01

Prüfen mit folgendem Befehl

getent hosts $(hostname -f)

Das Ergebniss muss ausehen wie die eingefügte Zeile in /etc/hosts

10.8.190.1 opsi-1-lnx01.opsi-1.local opsi-1-lnx01

/etc/nsswitch.conf beachten

Firewall und Forward

In die Datei /etc/rc.local folgende Zeilen VOR dem exit 0 als Minimum eintragen.
Dadurch wird das forwarding eingeschaltet, d.h. Pakete, die nicht für den Server sind, werden zu ihrem Ziel weiter geleitet.
iptables schaltet das masquerading ein. Dadurch erscheint das OPSI-Netzwerk nach außen wie ein Rechner. Ankommende Pakete werden anhand der POSTROUTING Tabelle im OPSI-Netzwerk verteilt.
Es existiert kein weiterer Schutz (dieser ist empfohlen!)

vim /etc/rc.local
echo 1 > /proc/sys/net/ipv4/ip_forward

iptables -F
iptables -t nat -F

iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE

Server Software installieren

nameserver

apt-get -y install bind9 dnsutils
zone file
mkdir /etc/bind/zones

Die Dateien opsi-1.local.zone und 190.8.10.in-addr.arpa im Verzeichniss /etc/bind/zones erzeugen.

  • opsi-1.local.zone => Zuständig für die Namensauflösung (Auflösen eines Namens in eine IP)
  • 190.8.10.in-addr.arpa.zone => Zuständig für reverse mapping (Auflösung der IP in einen Hostnamen)
zones einbinden

Eine Zone wird in

vim /etc/bind/named.conf.local 

eingebunden.

//
// Do any local configuration here
//
 
// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918"; 


zone "opsi-1.local" {
        type master;
        file "/etc/bind/zones/opsi-1.local.zone";
};

zone "190.8.10.in-addr.arpa" {
        type master;
        file "/etc/bind/zones/190.8.10.in-addr.arpa.zone";
};
opsi-1.local.zone
vim /etc/bind/zones/opsi-1.local.zone
; Kopf Start
; BIND zone file for opsi-1.local
;
$TTL    604800
@       IN      SOA     opsi-1-lnx01.opsi-1.local. admin.opsi-1.local. (
                        2014091001      ; Serial => JahrMonatTag0-99, ist willkürlich bis 4,294,967,295
                         604800         ; Refresh in Sekunden
                          86400         ; Retry in Sekunden
                        2419200         ; Expire in Sekunden
                         604800 )       ; Negative Cache TTL in Sekunden
;
@       IN      NS      opsi-1-lnx01.opsi-1.local.
; Kopf Ende
; Ab hier werden die Namen aufgelöst.
 
opsi-1-lnx01            IN A    10.8.190.1
server                  CNAME   opsi-1-lnx01
wpad                    CNAME   opsi-1-lnx01

printer01               IN A    10.8.190.31

win01                   IN A    10.8.190.101
win02                   IN A    10.8.190.102
win03                   IN A    10.8.190.103
win04                   IN A    10.8.190.104
win05                   IN A    10.8.190.105
190.8.10.in-addr.arpa.zone
vim /etc/bind/zones/190.8.10.in-addr.arpa.zone
;
; BIND zone file for 190.8.10.in-addr.arpa zone
;
$TTL    604800
@       IN      SOA     opsi-1-lnx01.opsi-1.local. admin.opsi-1.local. (
                       20140601801     ; Serial
                        604800         ; Refresh
                         86400         ; Retry
                       2419200         ; Expire
                        604800 )       ; Negative Cache TTL
;
@       IN      NS      opsi-1-lnx01.opsi-1.local.

 
 1                      IN PTR  opsi-1-lnx01.opsi-1.local.

31                      IN PTR  printer01.opsi-1.local.

101                     IN PTR  win01.opsi-1.local.
102                     IN PTR  win02.opsi-1.local.
103                     IN PTR  win03.opsi-1.local.
104                     IN PTR  win04.opsi-1.local.
DHCP-Client anpassen

Wenn der Server seine incoming IP über dhcp bezieht:
Damit unsere /etc/resolv.conf nicht andauernt überschrieben wird, muss das Verhalten des isc-dhcp-client geändert werden.

vim /etc/dhcp/dhclient.conf

Im Block request auskommentieren:

  • domain-name
  • domain-name-servers
  • domain-search
  • host-name
  • dhcp6.name-servers
  • dhcp6.domain-search,
  • netbios-name-servers

Damit haben wir noch ein paar weitere requests abgeschaltet. Sollte nicht schaden.

resolv.conf
vim /etc/resolv.conf
nameserver 127.0.0.1
search opsi-1.local

DHCP

apt-get install isc-dhcp-server
/etc/default/isc-dhcp-server

In /etc/default/isc-dhcp-server das etsprechende Netzwerkinterface eintragen, auf dem der DHCP-Server auf Anfragen lauschen soll.

vim /etc/default/isc-dhcp-server

In die Zeile

INTERFACES=""

das entsprechende Interface eintragen.
WICHTIG: Nur ein Interface darf rein, da die nc-opsi Tools darauf zurückgreifen!

INTERFACE="eth0"
/etc/dhcp/dhcpd.conf

Einträge für das Netzwerksegment 10.8.190.0/24.
dhcpd.conf leeren

echo > /etc/dhcp/dhcpd.conf
vim /etc/dhcp/dhcpd.conf
ddns-update-style none;
# Ist der offizielle DHCP-Server für alles in 10.8.190.0/24
authoritative;
# DNS-Domain-Name in der /etc/resolv.conf des Clienten
# Das ist nicht die Windows Domain
option domain-name "opsi-1.local";
# Nameserver
option domain-name-servers 10.8.190.1;
 
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
 
subnet 10.8.190.0 netmask 255.255.255.0 {
  # Der Range für nicht unten aufgeführte Computer per default abgeschaltet.
  # range 10.8.190.230 10.8.190.245;
  option routers 10.8.190.1;
  option broadcast-address 10.8.190.255;
  default-lease-time 600;
  max-lease-time 7200;
}


# Bei dieser Config werden die IPs über den nameserver aufgelöst.
 
host win01 { hardware ethernet 00:00:00:00:00:00;  fixed-address win01.opsi-1.local; }
host win02 { hardware ethernet 00:00:00:00:00:00;  fixed-address win02.opsi-1.local; }
host win03 { hardware ethernet 00:00:00:00:00:00;  fixed-address win03.opsi-1.local; }
host win04 { hardware ethernet 00:00:00:00:00:00;  fixed-address win04.opsi-1.local; }

Abhängigkeiten installieren

-y beantwortet die Frage nach dem "Soll installiert werden?" mit "Ja"

apt-get install -y wget lsof host python-mechanize p7zip-full cabextract openbsd-inetd samba samba-common smbclient cifs-utils samba-doc

In diesem Beispiel wird OPSI ohne mysql installiert

winbind abstellen

samba

/etc/samba/smb.conf

Bei der Installation von OPSI werden wir gefragt, ob wir Änderungen an der smb.conf zulassen wollen:
Wenn "ja", dann wurde der Block OPSI eingefügt:
Wir können aber die folgende smb.conf nutzen.
Dadurch wird samba zum Domänen-Controller im NT4-Style.
Der Name der Domäne ist OPSI-1
smb.conf ist buggy!

#
# /etc/samba/smb.conf
#

#======================= Global Settings =======================

[global]

  workgroup = OPSI-1
  server string = %h server
  wins support = no
;   wins server = w.x.y.z
  dns proxy = no
  name resolve order = lmhosts host wins bcast

#### Networking ####

  interfaces = 127.0.0.0/8 eth0
  bind interfaces only = yes


#### Debugging/Accounting ####

#   log file = /var/log/samba/log.%m
  log file = /var/log/samba/log.all
  max log size = 1000
  log level = 2
  panic action = /usr/share/samba/panic-action %d


####### Authentication #######

  security = user
  encrypt passwords = true
  passdb backend = tdbsam
  obey pam restrictions = yes
  unix password sync = no

  passwd program = /usr/bin/passwd %u
  passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .

  pam password change = yes

  map to guest = bad user

########## Domains ###########

  domain logons = yes
  logon path = \\%N\profiles\%a\%U
  logon drive = H:
#   logon home = \\%N\%U
;   logon script = logon.cmd

add machine script  = /usr/sbin/useradd -g machines -c "%u machine account" -d /var/lib/samba -s /bin/false %u

# Hide desktop.ini
  hide files = /desktop.ini/ntuser.ini/NTUSER.*/Thumbs.db/

########## Printing ##########

# If you want to automatically load your printer list rather
# than setting them up individually then you'll need this
#   load printers = yes

# lpr(ng) printing. You may wish to override the location of the
# printcap file
;   printing = bsd
;   printcap name = /etc/printcap

# CUPS printing.  See also the cupsaddsmb(8) manpage in the
# cupsys-client package.
;   printing = cups
;   printcap name = cups

############ Misc ############

  usershare allow guests = no

[homes]
  comment = Home Directories
  browseable = no
  read only = no
  create mask = 0700
  directory mask = 0700
  valid users = %S

[netlogon]
  comment = Network Logon Service
  path = /local/samba/netlogon
  guest ok = yes
  read only = yes

[profiles]
  comment = Users profiles
  path = /local/samba/profiles/
  guest ok = no
  read only = no
  browseable = no
  create mask = 0600
  directory mask = 0700

[printers]
  comment = All Printers
  browseable = no
  path = /var/spool/samba
  printable = yes
  guest ok = no
  read only = yes
  create mask = 0700

[print$]
  comment = Printer Drivers
  path = /var/lib/samba/printers
  browseable = yes
  read only = yes
  guest ok = no
  write list = root, @ntadmin

# OPSI

[opsi_depot]
  available = yes
  comment = opsi depot share (ro)
  path = /var/lib/opsi/depot
  oplocks = no
  follow symlinks = yes
  level2 oplocks = no
  writeable = no
  invalid users = root

[opsi_depot_rw]
  available = yes
  comment = opsi depot share (rw)
  path = /var/lib/opsi/depot
  oplocks = no
  follow symlinks = yes
  level2 oplocks = no
  writeable = yes
  invalid users = root

[opsi_images]
  available = yes
  comment = opsi ntfs images share (rw)
  path = /var/lib/opsi/ntfs-images
  oplocks = no
  level2 oplocks = no
  writeable = yes
  invalid users = root

[opsi_config]
  available = yes
  comment = opsi config share
  path = /var/lib/opsi/config
  writeable = yes
  invalid users = root

[opsi_workbench]
  available = yes
  comment = opsi workbench
  path = /home/opsiproducts
  writeable = yes
  invalid users = root
  create mask = 0660
  directory mask = 0770
  write list = @opsiadmin

[programme]
	path = /local/smb/shares/programme/
	comment = Programmdaten
	guest ok = no
	read only = no
	create mask = 0644
	directory mask = 2755
	force user = domainuser

[software]
	path = /local/smb/shares/software/
	comment = Softwarepakete
	guest ok = no
	read only = yes

Damit die neue Config wirksam werden kann, muss samba neu gestartet werden.

/etc/init.d/samba restart
Samba-User
Maschinenaccount

Damit add machine script aus der smb.conf funktioniert, muss die entsprechende Gruppe für die PCs angelegt werden.

groupadd machines
Benutzer

Das Setup bekommt drei Samba-User

  • domainadmin: Dieser User darf alles,
  • domainjoin: Dieser User darf PCs in die Domain aufnehmen
  • domainuser: Einfacher Benutzer, keinerlei administrative Rechte

Bei der Variante groupmap wird eine unix-group einer NT-Group zugewiesen.

groupadd ntadmin
net groupmap add ntgroup="Domain Admins" unixgroup=ntadmin rid=512 type=d

Die Mitglieder der Gruppe ntadmin sind gleichzeitig Domain Admins der Windows NT4-Style Domäne.

Die Benutzer werden mit useradd ohne weitere Optionen angelegt.
Dadurch wird kein Homeverzeichniss angelegt und nach keinem Password gefragt, so dass sich die Benutzer nicht am Server anmelden können.
Mit smbpasswd werden die Benutzer zu Samba hinzugefügt.

Bug: Homeverzeichniss für aktive Samba-User ist Pflicht!!!!
Durch die dritte Zeile wird der Benutzer domainadmin zum Domain Admin

useradd domainadmin
smbpasswd -a domainadmin
addgroup  domainadmin ntadmin

Durch die dritte Zeile bekommt der Benutzer das Recht, Maschinen zur Domain hinzuzufügen

useradd domainjoin
smbpasswd -a domainjoin
net rpc rights grant 'DOMAIN\domainjoin' SeMachineAccountPrivilege -U domainadmin
useradd domainuser
smbpasswd -a domainuser

OPSI installieren

Hinzufügen des Repositories

echo "deb http://download.opensuse.org/repositories/home:/uibmz:/opsi:/opsi40/Debian_7.0 ./" >> /etc/apt/sources.list.d/opsi.list

Signatur des Repositories importieren

wget -O - http://download.opensuse.org/repositories/home:/uibmz:/opsi:/opsi40/Debian_7.0/Release.key | apt-key add -

Der Erfolg kann mit

apt-key list

überprüft werden
Paketliste aktualisieren

apt-get update

System upgraden

apt-get upgrade -y

Die eigentlichen OPSI-Pakete installieren

apt-get install -y opsi-atftpd
apt-get install -y opsi-depotserver
apt-get install -y opsi-configed

Es fehlt nocht einiges.
opsi-getting-started




Anmerkungen

/opt/pcbin und das dazugehörige samba-share [opt_pcbin] ist eine OPSI-Altlast, die der Hersteller los werden will.
Paket winxppro ohne Verzeichnisstruktur in /opt/pcbin/install
Wenn sehr alte OPSI-Pakete eingesetzt werden, könnten wir allerdings darauf angewiesen sein.

Scripte

User automatisch anlegen: Entwurf


login=<USER>
pass=<PASSWRD>
options="" # zum Beispiel das Homeverzeichniss, die shell (/bin/false, /bin/bash)

useradd $login $options
echo -ne "$pass\n$pass\n" | smbpasswd -a -s $login


Mit net rpc rights grant den Benutzern winadmin alle Rechte und joindom "SeMachineAccountPrivilege" geben.
Altetnativ:

net groupmap add ntgroup="Domain Admins" unixgroup=ntadmin rid=512 type=d

Der bekannte winadmin muss alternativ der Gruppe ntadmin angehören.
Dann muss kein net rpc rights grant .... ausgeführt werden.

net groupmap add ntgroup="Domain Users" unixgroup=ntuser rid=513 type=d

Table 12.1. Well-Known User Default RIDs
Samba Docu: Table 12.1. Well-Known User Default RIDs




Später mal

OPSI

OPSI Installation Anleitung
opsi-getting-started-stable-en.pdf Anleitung auf English
opsi-getting-started-stable-de.pdf Anleitung auf Deutsch

/etc/fstab

Herausfinden und weiterverarbeiten der UUID

 blkid /dev/opsi_system/lv_local >> /etc/fstab

Am Ende herauskommen muss in der /etc/fstab etwas in der Art:

UUID=<UUID des lv_local>       /local  ext4    defaults        0       2

lv_local einbinden auf /local

cp -a /var/lib/opsi /local
rm -rf /var/lib/opsi
ln -s /local/opsi/ /var/lib/opsi