Grundlagen, allgemeines ####################### **Motivation:** Unsere heutigen PCs besitzen eine sehr hohe Rechenleistung und haben viel Plattenplatz, so dass sie ihre Ressourcen aufgeteilt und in Form von separaten, virtuellen Maschinen bereitgestellt werden können. Diese Art der Partitionierung gibt es in der Unix-Welt schon länger (z.B. BSD-Jails, Solaris-Zonen), unter Linux gibt es inzwischen auch einige Möglichkeiten. Außerdem können auch nur einzelne Anwendungen virtualisiert werden, wie es bei Containern und dem API-Übersetzer *wine* der Fall ist. Grundbegriffe, Einordnung ========================= Virtuell, emuliert und simuliert -------------------------------- Prinzipiell lassen sich drei große Kategorieren unterscheiden: Virtualisierung: Nicht real auf Hardware arbeitend, sondern in mehr oder weniger abgegrenzten, isolierten Prozessumgebungen, z.B.: **kvm** mit qemu oder libvirt, lxc, lxd, VirtualBox, Xen, ... => https://www.computerwoche.de/a/fuenf-beliebte-virtualisierer-fuer-linux-im-vergleich,3218056,3 Emulation: Nachstellen, nachempfinden von anderer Hardware, z.B. Rasperry Pi (ARM-Plattform) auf Intel-PCs ausführen, z.B.: **qemu** => https://en.wikipedia.org/wiki/QEMU API-Übersetzer/Wrapper: Via Application Programming Interface werden die Systemaufrufe verschiedener Plattformen übersetzt, z.B.: **wine** (Windows-API -> Linux) => `https://apfelböck.de/windows-software-unter-linux-wine-und-playonlinux/ `_ Der Begriff *Simulation* wird in der Regel etwas weiter gefasst, hier gibt es als spezielle Softwarelösung "GNS3", einen Open Source Netzwerksimulator, der mit virtuellen Maschinen arbeitet, so z.B.: - VPC (minimaler, virtueller builtin PC) - Qemu-Images (Vollvirtualisierung) - Docker-Container (leichtgewichtigte Anwendungsvirtualisierung, nur bedingt als VM nutzbar) Virtualisierung von Maschinen ----------------------------- Geht es speziell um die Virtualisierung von ganzen Maschinen, unterscheiden wir folgende Arten: Vollvirtualisierung: Kennzeichen: Vollständige Isolation der Gäste vom Hostsystem; die Gäste stellen richtige, kleine Maschinen mit eigener Festplatte, Bootloader und Kernel dar. Hierzu zählen **qemu**, VMware Workstation und VirtualBox. Bei dieser Art der Virtualisierung können die Gäste eine andere Prozessorarchitektur als die des Hosts aufweisen - die andere Architektur wird per Software nachgebildet, was sehr rechen- und damit zeitintensiv ist! Man spricht hier von Emulation (s.o.) Paravirtualisierung: Kennzeichen: Vollständige Isolation der Gäste vom Hostsystem; die Gäste müssen aber speziell angepasst werden, damit sie vom Hypervisor verwaltet werden können. Hierzu zählen **Xen**, User Mode Linux und u.U. auch VirtualBox. Kommt Hardwareunterstützung durch moderne CPUs hinzu (VT-Extensions), ist keine Anpassung der Gastbetriebssysteme nötig. Hierzu zählen dann **KVM**, Xen, VMware ESX und Hyper-V. Containervirtualisierung (in Unix: BSD-Jails, Solaris-Zonen): Dank der Control Groups (cgroups) des Linux-Kernels lassen sich die Resourcen gut partitionieren, wobei die Gäste mit ein und demselben Kernel des Hostsystems und seiner Laufzeitumgebung arbeiten. Ein Bootloader ist deshalb auch nicht erforderlich. Die bekannte Softwarelösung *Docker* hat sich speziell auf Anwendungsvirtualisierung ausgerichtet, typischerweise wird der Status der VM nach dem Ausschalten verworfen ("always fresh"). Hypervisor ---------- Der Hypervisor (= "Aufseher", der die Übersicht hat) ist eine Komponente, die auf dem Wirtssystem (= Host) selber läuft. Er übernimmt das Management der verschiedenen Gastsysteme (= Guests, VMs). Damit kann die Verwaltung der Ressourcen sowie des Start/Stop-Verhaltens und der Netzwerk- und Speicherkonfiguration (z.B. auch Snapshots) intelligent gestaltet werden. Einfachere Lösungen wie die klassischen Linux-Container (LXC) kommen ohne Hypervisor aus, wogegen es mit Canonicals LXD auch eine Art Aufseher für LXC gibt. Man unterscheidet klassischerweise zwei Hypervisor-Typen, wobei die Einordnung nicht sehr einheitlich gebraucht wird: - Typ-1: Der Hypervisor läuft direkt auf der Hardware (z.B. Xen, VMware ESXi, Hyper-V) - Typ-2: Der Hypervisor läuft innerhalb eines Betriebssystems, also "hosted" (z.B. KVM, VirtualBox, VMware Workstation) Unsere unter Linux zumeist verwendete Maschinenvirtualisierung ist KVM (Kernel based Virtual Machine). Diese Lösung arbeitet mit hardwareunterstützter Paravirtualisierung und stellt einen Typ-2 Hypervisor dar. Das heißt, es liegt ein ganz normal installierter Linux-Host mit spezieller CPU- und BIOS-Unterstützung vor (virtual extensions). Weitere Literatur ----------------- - https://kofler.info/free-ebooks/kvm-2012.pdf - https://www.xantaro.net/tech-blogs/hypervisor-basierte-virtualisierung/ - https://www.ionos.de/digitalguide/server/knowhow/was-ist-kvm/#c222180 - https://de.wikipedia.org/wiki/Hypervisor - https://www.elektronik-kompendium.de/sites/com/1101011.htm - https://www.linux-magazin.de/ausgaben/2017/02/bitparade/ - Grafische Desktop-Frontends Virtuelle Maschinen mit KVM =========================== Zuerst wollen wir uns an Kernel based Virtual Machines wagen, später dann an den Containerdienst LXD. Voraussetzungen --------------- Da es sich um hardwareunterstützte Paravirtualisierung handelt, muss die CPU bestimmte Fähigkeiten mitbringen, die auch via BIOS weitergereicht werden müssen (`zur Arktivierung bei Intel siehe hier... `_). All das prüfen wir zuerst mittels ``grep -E 'svm|vmx' /proc/cpuinfo``, taucht hierbei eins dieser beiden Muster auf, geht die Sache in Ordnung ("svm" = AMD-Prozessor, "vmx" = Intel-Prozessor). Wenn diese Unterstützung vorhanden ist, werden die passenden Module automatisch geladen, hier speziell für einen AMD-Prozessor: :: axl@idea:~$ lsmod | grep kvm kvm_amd 114688 0 kvm 827392 1 kvm_amd irqbypass 16384 1 kvm ccp 106496 1 kvm_amd axl@idea:~$ Bei einer Intel-CPU würden dann die Module *kvm.ko* und *kvm-intel.ko* geladen. **Nested virtualization:** Die native, hardwareseitige Unterstützung bieten AMD und Intel schon seit 2006 an. Daher sollten Gäste dank KVM äußerst performant auf modernerer Hardware laufen. Anderes sieht es aus, wenn es um Linux-Gastsysteme geht, die sich bereits in einer virtualisierten Umgebung befinden. Dort muss dann häufig emuliert werden, was viel Zeit kostet. Falls aber die CPU und die Virtualisierungssoftware "Nested virtualization" unterstützen, kann auch hier direkt auf KVM gesetzt werden. Bei VirtualBox ist dies in den *Einstellungen* der jeweiligen VM unter *System -> Prozessor -> VT-x/AMD-V aktivieren* zu finden (`siehe dazu hier `_). Wenn diese Option ausgegraut ist, wird es zumeist daran liegen, dass dieses Feature nicht von der CPU unterstützt wird. Installation ------------ Die Software ist schnell installiert, wir benötigen lediglich die Virtualisierungsumgebung 'qemu', die oben genannten Kernelmodule werden mit dem Kernel ausgeliefert. Die Zeile ``apt-get install qemu-system-x86 qemu-kvm`` erledigt dies unter Debian - unter Arch/Artix Linux schreibt man ``pacman -Sy qemu``. Danach sollten wir mit ``usermod -aG kvm tux`` unseren Standardnutzer *tux* noch in die neue Gruppe *kvm* hieven, damit er dann Maschinen an den Start bringen kann. Damit sich das auswirken kann, muss er sich schließlich an allen Konsolen/GUI-Sitzungen aus- und wieder einloggen. Erster Start ------------ Im einfachsten Fall konfigurieren wir unsere VM mit einer kurzen Zeile. Damit sie wirklich kurz bleibt, ist das obige Debianpaket *qemu-kvm* anzuraten, das nur einen Wrapper um ``qemu-system-x86_64 -enable-kvm`` darstellt. Auf anderen Distributionen kann man sich einen Alias mittels ``echo "alias kvm='qemu-system-x86_64 -enable-kvm'" >> ~/.bashrc && source ~/.bashrc`` einrichten, der dann auch gleich persistent ist. Hierzu drei Beispiele: 1. Eine VM mit 1500 MB Speicher, Standardgrafikkarte und bootfähiger Live-Linux-Distribution (ohne Festplatte): :: kvm -m 1500 -vga std -cdrom myLiveLinux.iso 2. Eine VM mit 1500 MB Speicher, Standardgrafikkarte, neu zu erzeugender Festplatte und bootfähiger, installierbarer Linux-Distribution: :: qemu-img create -f qcow2 myLinuxHDD.img 50G kvm -m 1500 -vga std -hda myLinuxHDD.img -cdrom myLinuxDVD.iso 3. Eine VM mit 1500 MB Speicher, Standardgrafikkarte, zuerst von Festplatte bootend, mit Festplatte und Linux-Distribution, wobei mit ``-usb -device usb-tablet`` die Bewegungen der Maus aufgrund von absoluten Koordinaten berechnet werden, was die Verwendung virtueller Zeigegeräte im Gast vereinfacht, weil dazu keine Gasterweiterungen erforderlich sind: :: kvm -m 1500 -vga std -boot c -hda myLinuxHDD.img -cdrom myLinuxDVD.iso -usb -device usb-tablet Auf diese Weise können die VMs leicht auf die jeweiligen Bedürfnisse zugeschnitten werden. Auch weitere virtuelle Festplatten sind kein Problem, dazu muss nur mittels ``qemu-img`` ein neues Image erzeugt (siehe bei Punkt 2) und mit ``-hdb `` oder bei einer dritten Platte mit ``-hdc `` eingebunden werden. Overlay-Dateien für komfortable Snapshots ----------------------------------------- Neben internen Snapshots gibt es die flexiblere Möglichkeit, die externen Dateien Eine Festplatten-Image im Copy-on-Write-Format von 20 GB Größe erzeugen: ``qemu-img create -f qcow2 linux-hdd.img 20G`` Eine Overlay-Datei für ein gegebenes Image erzeugen: ``qemu-img create -f qcow2 -o backing_file=basis.img overlay.img`` Aus ``man qemu-img``: :: If the option BACKING_FILE is specified, then the image will record only the differences from BACKING_FILE. No size needs to be specified in this case. BACKING_FILE will never be modified unless you use the commit monitor command (or 'qemu-img commit'). Netzwerk via NAT und Port-Forwarding ------------------------------------ In Arbeit... :: qemu-system-x86_64 --enable-kvm -m 1500 -hda /home/axl/VMs/Debian10-mit-Openbox-disk0002.qcow2 -vga std \ -net nic,model=rtl8139 -net user,hostfwd=tcp::2222-:22 \ -device usb-ehci,id=ehci -device usb-host,id=ralink,bus=ehci.0,vendorid=0x148f,productid=0x5370 axl@idea:~$ ~/VMs/starting.buster & [1] 4634 axl@idea:~$ axl@idea:~$ # Nach dem Starten sind Prozesse da: axl@idea:~$ ps -A | grep -i qemu 4635 pts/0 00:00:22 qemu-system-x86 axl@idea:~$ axl@idea:~$ axl@idea:~$ ## Dies ist der Kernel des Host-System: axl@idea:~$ uname -r 5.9.0-0.bpo.2-amd64 axl@idea:~$ axl@idea:~$ axl@idea:~$ ## Login in den Gast via Port-Forwarding: axl@idea:~$ ssh -p 2222 tux@localhost tux@localhost's password: Linux deb10 4.19.0-13-amd64 #1 SMP Debian 4.19.160-2 (2020-11-28) x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Tue Jan 26 10:20:14 2021 from 10.0.2.2 tux@deb10:~$ tux@deb10:~$ tux@deb10:~$ ## Dies ist der Kernel des Gast-Systems: tux@deb10:~$ uname -r 4.19.0-13-amd64 tux@deb10:~$ tux@deb10:~$ # >> alles wie in einer richtigen Maschine: voll virtualisiert! tux@deb10:~$ tux@deb10:~$ ls -l /boot/ insgesamt 77984 -rw-r--r-- 1 root root 206269 Nov 28 08:47 config-4.19.0-13-amd64 -rw-r--r-- 1 root root 206157 Jun 7 2020 config-4.19.0-9-amd64 drwxr-xr-x 5 root root 4096 Jan 22 12:27 grub -rw-r--r-- 1 root root 36219224 Jan 22 14:40 initrd.img-4.19.0-13-amd64 -rw-r--r-- 1 root root 25817893 Jan 18 14:09 initrd.img-4.19.0-9-amd64 -rw-r--r-- 1 root root 3419998 Nov 28 08:47 System.map-4.19.0-13-amd64 -rw-r--r-- 1 root root 3411735 Jun 7 2020 System.map-4.19.0-9-amd64 -rw-r--r-- 1 root root 5283056 Nov 28 08:47 vmlinuz-4.19.0-13-amd64 -rw-r--r-- 1 root root 5274864 Jun 7 2020 vmlinuz-4.19.0-9-amd64 tux@deb10:~$ tux@deb10:~$ grep vmlinuz /boot/grub/grub.cfg linux /boot/vmlinuz-4.19.0-13-amd64 root=UUID=aba84e74-e806-437b-a1ca-e28e4e93b7b5 ro quiet linux /boot/vmlinuz-4.19.0-13-amd64 root=UUID=aba84e74-e806-437b-a1ca-e28e4e93b7b5 ro quiet linux /boot/vmlinuz-4.19.0-13-amd64 root=UUID=aba84e74-e806-437b-a1ca-e28e4e93b7b5 ro single linux /boot/vmlinuz-4.19.0-9-amd64 root=UUID=aba84e74-e806-437b-a1ca-e28e4e93b7b5 ro quiet linux /boot/vmlinuz-4.19.0-9-amd64 root=UUID=aba84e74-e806-437b-a1ca-e28e4e93b7b5 ro single tux@deb10:~$ tux@deb10:~$ axl@idea:~$ # Installierte Software für den Linux-Host: axl@idea:~$ dpkg -l | grep kvm ii qemu-kvm 1:3.1+dfsg-8+deb10u8 amd64 QEMU Full virtualization on x86 hardware axl@idea:~$ axl@idea:~$ dpkg -l | grep qemu ii ipxe-qemu 1.0.0+git-20190125.36a4c85-1 all PXE boot firmware - ROM images for qemu ii qemu-kvm 1:3.1+dfsg-8+deb10u8 amd64 QEMU Full virtualization on x86 hardware ii qemu-system-common 1:3.1+dfsg-8+deb10u8 amd64 QEMU full system emulation binaries (common files) ii qemu-system-data 1:3.1+dfsg-8+deb10u8 all QEMU full system emulation (data files) ii qemu-system-gui 1:3.1+dfsg-8+deb10u8 amd64 QEMU full system emulation binaries (user interface and audio support) ii qemu-system-x86 1:3.1+dfsg-8+deb10u8 amd64 QEMU full system emulation binaries (x86) ii qemu-utils 1:3.1+dfsg-8+deb10u8 amd64 QEMU utilities axl@idea:~$ axl@idea:~$ axl@idea:~$ # Die Kernel-Module muss man nicht nachinstallieren, sie werden mit dem Kernel ausgeliefert. axl@idea:~$ axl@idea:~$ Klonen von VMs ============== Je nach Virtualisierungssoftware wird die Original-VM kopiert und "uniq" eingebunden. Nach dem ersten Starten der kopierten, neuen VM wichtig: 1. Maschinen-ID ändern: /etc/machine-id (Kommandos: dbus-uuidgen, systemd-machine-id-setup, => S. 88) 2. Secure-Shell Host-Schlüsseln erneuern: Kommando ssh-keygen 3. Evl. auch IP-Adresse ändern 4. Hostname ändern :: tux@deb10:~$ tux@deb10:~$ ## Maschinen-ID ändern: tux@deb10:~$ su - Passwort: root@deb10:~# cat /etc/machine-id 076557a9029341909a227d1e164f5411 root@deb10:~# root@deb10:~# ls -l /etc/machine-id -r--r--r-- 1 root root 33 Jan 18 14:03 /etc/machine-id root@deb10:~# root@deb10:~# rm /etc/machine-id root@deb10:~# root@deb10:~# rm /var/lib/dbus/machine-id root@deb10:~# root@deb10:~# systemd-machine-id-setup Initializing machine ID from random generator. root@deb10:~# root@deb10:~# root@deb10:~# cat /etc/machine-id 7fcf4ef042c74f57879900dc6891d00e root@deb10:~# root@deb10:~# root@deb10:~# root@deb10:~# ## Alternativ nimmt man auf Linux-Systemen ohne systemd dieses Kommando: root@deb10:~# dbus-uuidgen d9eedf506524e4b84b198d6b60114a9a root@deb10:~# root@deb10:~# dbus-uuidgen 2513e1fac54ac94be581de6d60114a9b root@deb10:~# root@deb10:~# dbus-uuidgen 626291105c276810fc21423960114a9d root@deb10:~# root@deb10:~# root@deb10:~# root@deb10:~# # Insgesamt: root@deb10:~# # rm /etc/machine-id /var/lib/dbus/machine-id root@deb10:~# # dbus-uuidgen --ensure=/etc/machine-id root@deb10:~# root@deb10:~# root@deb10:~# # Weitere Begriffe (S. 90 f): root@deb10:~# root@deb10:~# # - Zugriff auf Ressourcen von überall aus (Outsourcing): IaaS root@deb10:~# # - Anpassungen nach dem Klonen automatisieren (Machine-ID, SSH-Keys, IP-Addr., ...): Paket "cloud-init" Einrichtung von LXD =================== (ausgesprochen: Lex Dee) Die schlanke von Ubuntu stammende Hypervisorlösung für Linux-Container (LXC) ist dank Ubuntus Snap-Repo schnell installiert. :: root@deb10:~# apt-cache search lxd container resource-agents - Cluster Resource Agents root@deb10:~# root@deb10:~# root@deb10:~# apt-cache search ^snapd snapd - Daemon und Werkzeuge, die Snap-Pakete aktivieren node-snapdragon-node - Snapdragon utility to create a new AST node in some node qml-module-snapd - Snapd QML module root@deb10:~# root@deb10:~# apt-get install snapd Vormals nicht ausgewähltes Paket snapd wird gewählt. Vorbereitung zum Entpacken von .../snapd_2.37.4-1+b1_amd64.deb ... Entpacken von snapd (2.37.4-1+b1) ... liblzo2-2:amd64 (2.10-0.1) wird eingerichtet ... squashfs-tools (1:4.3-12) wird eingerichtet ... snapd (2.37.4-1+b1) wird eingerichtet ... Created symlink /etc/systemd/system/multi-user.target.wants/snapd.seeded.service → /lib/systemd/system/snapd.seeded.service. Created symlink /etc/systemd/system/cloud-final.service.wants/snapd.seeded.service → /lib/systemd/system/snapd.seeded.service. Created symlink /etc/systemd/system/multi-user.target.wants/snapd.service → /lib/systemd/system/snapd.service. Created symlink /etc/systemd/system/sockets.target.wants/snapd.socket → /lib/systemd/system/snapd.socket. Trigger für desktop-file-utils (0.23-4) werden verarbeitet ... Trigger für mime-support (3.62) werden verarbeitet ... Trigger für libc-bin (2.28-10) werden verarbeitet ... Trigger für man-db (2.8.5-2) werden verarbeitet ... Trigger für bamfdaemon (0.5.4-1) werden verarbeitet ... Rebuilding /usr/share/applications/bamf-2.index... root@deb10:~# root@deb10:~# root@deb10:~# whatis snap snap (8) - Tool to interact with snaps root@deb10:~# root@deb10:~# root@deb10:~# snap search lxd Name Version Publisher Notes Summary lxd 4.10 canonical✓ - System container manager and API lxd-bgp 0+git.4f506d5 stgraber - BGP server that exposes LXD routes lxd-demo-server 0+git.6d54658 stgraber - Online software demo sessions using LXD lxdmosaic 0+git.1aa9154 turtle0x1 - A web interface to manage multiple instances of LXD fabrica 1.1.0 ogra - Build snaps by simply pointing a web form to a git tree nova ocata james-page - OpenStack Compute Service (nova) nova-hypervisor ocata james-page - OpenStack Compute Service - KVM Hypervisor (nova) distrobuilder 1.1 stgraber classic Image builder for LXC and LXD satellite 0.1.2 alanzanattadev - Advanced scalable Open source intelligence platform root@deb10:~# root@deb10:~# root@deb10:~# snap install lxd Download snap "core18" (1944) from channel "stable" 62% 6.27MB/s 3.50serror: cannot perform the following tasks: - Mount snap "lxd" (19009) (snap "lxd" assumes unsupported features: snapd2.39 (try to update snapd and refresh the core snap)) root@deb10:~# root@deb10:~# root@deb10:~# snap install core 2021-01-27T12:38:52+01:00 INFO Waiting for restart... core 16-2.48.2 from Canonical✓ installed Channel latest/stable for core is closed; temporarily forwarding to stable. root@deb10:~# root@deb10:~# root@deb10:~# snap install lxd Warning: /snap/bin was not found in your $PATH. If you've not restarted your session since you installed snapd, try doing that. Please see https://forum.snapcraft.io/t/9469 for more details. lxd 4.10 from Canonical✓ installed root@deb10:~# root@deb10:~# root@deb10:~# ls -l /snap/bin/ insgesamt 0 lrwxrwxrwx 1 root root 7 Jan 27 12:40 lxc -> lxd.lxc lrwxrwxrwx 1 root root 13 Jan 27 12:40 lxd -> /usr/bin/snap lrwxrwxrwx 1 root root 13 Jan 27 12:40 lxd.benchmark -> /usr/bin/snap lrwxrwxrwx 1 root root 13 Jan 27 12:40 lxd.buginfo -> /usr/bin/snap lrwxrwxrwx 1 root root 13 Jan 27 12:40 lxd.check-kernel -> /usr/bin/snap lrwxrwxrwx 1 root root 13 Jan 27 12:40 lxd.lxc -> /usr/bin/snap lrwxrwxrwx 1 root root 13 Jan 27 12:40 lxd.lxc-to-lxd -> /usr/bin/snap lrwxrwxrwx 1 root root 13 Jan 27 12:40 lxd.migrate -> /usr/bin/snap root@deb10:~# root@deb10:~# root@deb10:~# ## Nochmal im Überblick: root@deb10:~# root@deb10:~# # a) apt-get install snapd root@deb10:~# # b) snap install core root@deb10:~# # c) snap install lxd root@deb10:~# root@deb10:~# root@deb10:~# # Nun stecken wir unseren Hauptnutzer in die Gruppe neue 'lxd': root@deb10:~# grep lxd /etc/group lxd:x:997: root@deb10:~# root@deb10:~# usermod -aG lxd tux root@deb10:~# root@deb10:~# groups tux tux : tux cdrom floppy audio dip video plugdev netdev bluetooth lxd root@deb10:~# root@deb10:~# root@deb10:~# ## Nun bitte gründlich von JEDER KONSOLE/DESKTOP aus- und wieder einloggen... root@deb10:~# root@deb10:~# exit Abgemeldet tux@deb10:~$ exit Abgemeldet Connection to localhost closed. axl@idea:~$ axl@idea:~$ axl@idea:~$ ssh -p 2222 tux@localhost tux@localhost's password: Linux deb10 4.19.0-13-amd64 #1 SMP Debian 4.19.160-2 (2020-11-28) x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Wed Jan 27 11:22:15 2021 from 10.0.2.2 tux@deb10:~$ tux@deb10:~$ su - Passwort: root@deb10:~# root@deb10:~# echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin root@deb10:~# root@deb10:~# # >> Jetzt ist auch "/snap/bin" im Suchpfad enthalten. :-) root@deb10:~# root@deb10:~# root@deb10:~# history 33 250 whatis snap 251 snap install lxd 252 whatis lxd 253 whatis lxc 254 snap install lxd 255 snap install core 256 snap install lxd 257 # >> Jetzt ist es OK. 258 whatis lxd 259 whatis lxc 260 which lxc 261 ls -l /snap/bin/ 262 cal 263 # apt-get install snapd 264 ## Nochmal im Überblick: 265 # a) apt-get install snapd 266 # b) snap install core 267 # c) snap install lxd 268 mount | grep btrfs 269 # Nun stecken wir unseren Hauptnutzer in die Gruppe neue 'lxd': 270 grep lxd /etc/group 271 usermod -aG lxd tux 272 groups tux 273 ## Nun bitte gründlich von JEDER KONSOLE/DESKTOP aus- und wieder einloggen... 274 exit 275 ip -4 addr 276 dhclient 277 ip -4 addr 278 killall X 279 killall Xorg 280 echo $PATH 281 # >> Jetzt ist auch "/snap/bin" im Suchpfad enthalten. :-) 282 history 33 root@deb10:~# root@deb10:~# root@deb10:~# root@deb10:~# ## Nun muss anschließend der Hypervisor konfiguriert und gestartet werden: root@deb10:~# lxd init root@deb10:~# root@deb10:~# ## Nun muss anschließend der Hypervisor konfiguriert und gestartet werden: root@deb10:~# lxd init Would you like to use LXD clustering? (yes/no) [default=no]: Do you want to configure a new storage pool? (yes/no) [default=yes]: Name of the new storage pool [default=default]: Name of the storage backend to use (btrfs, dir, lvm, ceph) [default=btrfs]: dir Would you like to connect to a MAAS server? (yes/no) [default=no]: Would you like to create a new local network bridge? (yes/no) [default=yes]: What should the new bridge be called? [default=lxdbr0]: What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: Would you like the LXD server to be available over the network? (yes/no) [default=no]: Would you like stale cached images to be updated automatically? (yes/no) [default=yes] Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]: qemu-system-x86_64: external icmpv6 not supported yet root@deb10:~# root@deb10:~# root@deb10:~# root@deb10:~# whatis pgrep pgrep (1) - look up or signal processes based on name and other attributes root@deb10:~# root@deb10:~# pgrep -alfi lx 2369 /bin/sh /snap/lxd/19009/commands/daemon.start 2518 lxcfs /var/snap/lxd/common/var/lib/lxcfs -p /var/snap/lxd/common/lxcfs.pid 2529 lxd --logfile /var/snap/lxd/common/lxd/logs/lxd.log --group lxd 2715 dnsmasq --keep-in-foreground --strict-order --bind-interfaces --except-interface=lo --pid-file= --no-ping --interface=lxdbr0 --quiet-dhcp --quiet-dhcp6 --quiet-ra --listen-address=10.234.55.1 --dhcp-no-override --dhcp-authoritative --dhcp-leasefile=/var/snap/lxd/common/lxd/networks/lxdbr0/dnsmasq.leases --dhcp-hostsfile=/var/snap/lxd/common/lxd/networks/lxdbr0/dnsmasq.hosts --dhcp-range 10.234.55.2,10.234.55.254,1h --listen-address=fd42:13d0:a9c9:ecdb::1 --enable-ra --dhcp-range ::,constructor:lxdbr0,ra-stateless,ra-names -s lxd -S /lxd/ --conf-file=/var/snap/lxd/common/lxd/networks/lxdbr0/dnsmasq.raw -u lxd -g lxd root@deb10:~# root@deb10:~# root@deb10:~# systemctl list-unit-files | grep lx snap-lxd-19009.mount enabled snap.lxd.activate.service enabled snap.lxd.daemon.service static snap.lxd.daemon.unix.socket enabled root@deb10:~# root@deb10:~# systemctl status snap.lxd.daemon ● snap.lxd.daemon.service - Service for snap application lxd.daemon Loaded: loaded (/etc/systemd/system/snap.lxd.daemon.service; static; vendor preset: enabled) Active: active (running) since Wed 2021-01-27 13:32:09 CET; 9min ago Main PID: 2369 (daemon.start) Tasks: 0 (limit: 1699) Memory: 25.8M CGroup: /system.slice/snap.lxd.daemon.service ‣ 2369 /bin/sh /snap/lxd/19009/commands/daemon.start Jan 27 13:32:10 deb10 lxd.daemon[2369]: - proc_uptime Jan 27 13:32:10 deb10 lxd.daemon[2369]: - shared_pidns Jan 27 13:32:10 deb10 lxd.daemon[2369]: - cpuview_daemon Jan 27 13:32:10 deb10 lxd.daemon[2369]: - loadavg_daemon Jan 27 13:32:10 deb10 lxd.daemon[2369]: - pidfds Jan 27 13:32:11 deb10 lxd.daemon[2369]: => Starting LXD Jan 27 13:32:13 deb10 lxd.daemon[2369]: t=2021-01-27T13:32:13+0100 lvl=warn msg=" - Couldn't find the CGroup hugetlb c Jan 27 13:32:13 deb10 lxd.daemon[2369]: t=2021-01-27T13:32:13+0100 lvl=warn msg=" - Couldn't find the CGroup memory sw Jan 27 13:32:15 deb10 lxd.daemon[2369]: => First LXD execution on this system Jan 27 13:32:15 deb10 lxd.daemon[2369]: => LXD is ready root@deb10:~# root@deb10:~# tux@deb10:~$ ## Nun kann der User loslegen: tux@deb10:~$ lxc list +------+-------+------+------+------+-----------+ | NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS | +------+-------+------+------+------+-----------+ tux@deb10:~$ tux@deb10:~$ lxc profile list +---------+---------+ | NAME | USED BY | +---------+---------+ | default | 0 | +---------+---------+ tux@deb10:~$ tux@deb10:~$ lxc network list +--------+----------+---------+----------------+---------------------------+-------------+---------+ | NAME | TYPE | MANAGED | IPV4 | IPV6 | DESCRIPTION | USED BY | +--------+----------+---------+----------------+---------------------------+-------------+---------+ | ens3 | physical | NO | | | | 0 | +--------+----------+---------+----------------+---------------------------+-------------+---------+ | lxdbr0 | bridge | YES | 10.234.55.1/24 | fd42:13d0:a9c9:ecdb::1/64 | | 1 | +--------+----------+---------+----------------+---------------------------+-------------+---------+ tux@deb10:~$ tux@deb10:~$ # >> fresh install. tux@deb10:~$ tux@deb10:~$ tux@deb10:~$ ## Das erste Gastsystem soll das kleine Alpine Linux werden: tux@deb10:~$ lxc launch images:alpine/3.12 alpine-01 Creating alpine-01 Starting alpine-01 tux@deb10:~$ tux@deb10:~$ tux@deb10:~$ history 21 94 # 95 # Nach dem Starten der kopierten, neuen VM wichtig: 96 # 1. Maschinen-ID ändern: /etc/machine-id (Kommandos: dbus-uuidgen, systemd-machine-id-setup, => S. 88) 97 # 2. Secure-Shell Host-Schlüsseln erneuern: Kommando ssh-keygen 98 # 3. Evl. auch IP-Adresse ändern 99 # 4. Hostname ändern 100 ## Maschinen-ID ändern: 101 su - 102 exit 103 ls -l /boot 104 su - 105 ## Nun kann der User loslegen: 106 lxc list 107 lxc profile list 108 lxc network list 109 # >> fresh install. 110 ## Das erste Gastsystem soll das kleine Alpine Linux werden: 111 lxc launch images:alpine/3.9 alpine-01 112 lxc launch images:alpine/3.12 alpine-01 113 lxc list 114 history 21 tux@deb10:~$ tux@deb10:~$ tux@deb10:~$ tux@deb10:~$ lxc list +-----------+---------+---------------------+----------------------------------------------+-----------+-----------+ | NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS | +-----------+---------+---------------------+----------------------------------------------+-----------+-----------+ | alpine-01 | RUNNING | 10.234.55.51 (eth0) | fd42:13d0:a9c9:ecdb:216:3eff:fec8:727 (eth0) | CONTAINER | 0 | +-----------+---------+---------------------+----------------------------------------------+-----------+-----------+ tux@deb10:~$ tux@deb10:~$ ## In den laufenden Container wechseln: tux@deb10:~$ lxc exec alpine-01 ash ~ # ~ # # >> Schon drin. ~ # ~ # ~ # ## Wir haben hier keine Bash als Shell (Kommandozeileninterpreter): ~ # echo $0 ash ~ # ~ # bash ash: bash: not found ~ # ~ # cal January 2021 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 ~ # ~ # df -h Filesystem Size Used Available Use% Mounted on /dev/sda1 48.0G 3.0G 42.5G 7% / none 492.0K 4.0K 488.0K 1% /dev udev 708.2M 0 708.2M 0% /dev/fuse udev 708.2M 0 708.2M 0% /dev/net/tun tmpfs 100.0K 0 100.0K 0% /dev/lxd tmpfs 100.0K 0 100.0K 0% /dev/.lxd-mounts udev 708.2M 0 708.2M 0% /dev/full udev 708.2M 0 708.2M 0% /dev/null udev 708.2M 0 708.2M 0% /dev/random udev 708.2M 0 708.2M 0% /dev/tty udev 708.2M 0 708.2M 0% /dev/urandom udev 708.2M 0 708.2M 0% /dev/zero none 492.0K 4.0K 488.0K 1% /proc/sys/kernel/random/boot_id tmpfs 145.5M 52.0K 145.5M 0% /run ~ # ~ # # >> "disk free" zeigt die Ressourcen des äußeren Hosts an! ~ # ~ # du -sh / du: can't open '/dev/.lxd-mounts': Permission denied du: can't open '/sys/kernel/tracing': Permission denied du: can't open '/sys/kernel/debug': Permission denied du: can't open '/sys/fs/pstore': Permission denied du: can't open '/proc/sys/fs/binfmt_misc': Permission denied du: can't open '/proc/tty/driver': Permission denied 8.7M / ~ # ~ # # >> "disk usage" kann aber nun mittels Summenberechnung sagen, was es wirklich benötigt. ~ # ~ # ~ # ## Wir sind hier 'root': ~ # whoami root ~ # ~ # id uid=0(root) gid=0(root) ~ # ~ # ~ # ps -A PID USER TIME COMMAND 1 root 0:00 /sbin/init 223 root 0:00 /sbin/syslogd -t 250 root 0:00 /usr/sbin/crond -c /etc/crontabs 294 root 0:00 udhcpc -b -R -p /var/run/udhcpc.eth0.pid -i eth0 -x hostname:alpine-01 345 root 0:00 /sbin/getty 38400 console 346 root 0:00 ash 353 root 0:00 ps -A ~ # ~ # ~ # ~ # ~ # ## Wir sind auch schon im Internet: ~ # ip -4 addr 1: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1000 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever 4: eth0@if5: mtu 1500 qdisc noqueue state UP qlen 1000 inet 10.234.55.51/24 brd 10.234.55.255 scope global eth0 valid_lft forever preferred_lft forever ~ # ~ # ip route default via 10.234.55.1 dev eth0 metric 204 10.234.55.0/24 dev eth0 scope link src 10.234.55.51 ~ # ~ # cat /etc/resolv.conf search lxd nameserver 10.234.55.1 ~ # ~ # ~ # ~ # ## Software installieren: ~ # apk update fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz v3.12.3-80-g1b5dbce3e9 [http://dl-cdn.alpinelinux.org/alpine/v3.12/main] v3.12.3-77-g89584230ef [http://dl-cdn.alpinelinux.org/alpine/v3.12/community] OK: 12747 distinct packages available ~ # ~ # apk add bash nano openssh-server (1/9) Installing ncurses-terminfo-base (6.2_p20200523-r0) (2/9) Installing ncurses-libs (6.2_p20200523-r0) (3/9) Installing readline (8.0.4-r0) (4/9) Installing bash (5.0.17-r0) Executing bash-5.0.17-r0.post-install (5/9) Installing libmagic (5.38-r0) (6/9) Installing nano (4.9.3-r0) (7/9) Installing openssh-keygen (8.3_p1-r1) (8/9) Installing openssh-server-common (8.3_p1-r1) (9/9) Installing openssh-server (8.3_p1-r1) Executing busybox-1.31.1-r19.trigger OK: 18 MiB in 28 packages ~ # ~ # ~ # ## Mittels diesem Init-Daemons (OpenRC) den SSH-Server starten und für Autostart konfigurieren: ~ # rc-service sshd start * Caching service dependencies ... [ ok ] ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519 * Starting sshd ... [ ok ] ~ # ~ # ~ # rc-update bootmisc | boot crond | default networking | default syslog | boot ~ # ~ # ~ # rc-update add sshd * service sshd added to runlevel default ~ # ~ # rc-update bootmisc | boot crond | default networking | default sshd | default syslog | boot ~ # ~ # ~ # exit tux@deb10:~$ tux@deb10:~$ tux@deb10:~$ lxc list +-----------+---------+---------------------+----------------------------------------------+-----------+-----------+ | NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS | +-----------+---------+---------------------+----------------------------------------------+-----------+-----------+ | alpine-01 | RUNNING | 10.234.55.51 (eth0) | fd42:13d0:a9c9:ecdb:216:3eff:fec8:727 (eth0) | CONTAINER | 0 | +-----------+---------+---------------------+----------------------------------------------+-----------+-----------+ tux@deb10:~$ tux@deb10:~$ tux@deb10:~$ # >> Hat wieder dieselbe IP-Addresse erhalten... tux@deb10:~$ tux@deb10:~$ tux@deb10:~$ ## Mit ssh Verbindung herstellen: tux@deb10:~$ ssh root@10.234.55.51 The authenticity of host '10.234.55.51 (10.234.55.51)' can't be established. ECDSA key fingerprint is SHA256:AHhgmJjndWNGHnmzj4WWWLdUWavRlPdqmcE/XwrLSQw. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '10.234.55.51' (ECDSA) to the list of known hosts. root@10.234.55.51's password: Permission denied, please try again. root@10.234.55.51's password: tux@deb10:~$ tux@deb10:~$ tux@deb10:~$ # >> Sorry, vergessen Nutzer anzulegen, ... tux@deb10:~$ tux@deb10:~$ tux@deb10:~$ tux@deb10:~$ ## Wir versuchen von außen das root-Passwort zu setzen: tux@deb10:~$ lxc exec alpine-01 passwd root Changing password for root New password: Bad password: too short Retype password: passwd: password for root changed by root tux@deb10:~$ tux@deb10:~$ # >> hat offenbar geklappt. tux@deb10:~$ tux@deb10:~$ tux@deb10:~$ ## Wir versuchen nun den ssh-Login als root durchzuführen: tux@deb10:~$ ssh root@10.234.55.51 root@10.234.55.51's password: Permission denied, please try again. root@10.234.55.51's password: Permission denied, please try again. root@10.234.55.51's password: root@10.234.55.51: Permission denied (publickey,password,keyboard-interactive). tux@deb10:~$ tux@deb10:~$ # >> Ist bei Alpine NICHT erlaubt (/etc/ssh/sshd_config: "PermitRootLogin no")! tux@deb10:~$ tux@deb10:~$ tux@deb10:~$ tux@deb10:~$ # Von außen einen Nutzer anlegen: tux@deb10:~$ lxc exec alpine-01 adduser tux Changing password for tux New password: Bad password: too short Retype password: passwd: password for tux changed by root tux@deb10:~$ tux@deb10:~$ ssh tux@10.234.55.51 tux@10.234.55.51's password: Welcome to Alpine! The Alpine Wiki contains a large amount of how-to guides and general information about administrating Alpine systems. See . You can setup the system with the command: setup-alpine You may change this message by editing /etc/motd. alpine-01:~$ alpine-01:~$ # >> Endlich via SSH drin. :-) alpine-01:~$ alpine-01:~$ alpine-01:~$ /bin/su - Password: alpine-01:~# alpine-01:~# # >> Sicher 'root' zu werden bedeutet, absolute Pfade zu benutzen! alpine-01:~# alpine-01:~# which nano /usr/bin/nano alpine-01:~# alpine-01:~# alpine-01:~# alpine-01:~# ## Zur Kontrolle/Detection, dass wir in einem Conatainer sind: alpine-01:~# ls -la /boot ls: /boot: No such file or directory alpine-01:~# alpine-01:~# uname -r 4.19.0-13-amd64 alpine-01:~# alpine-01:~# find / -name "*4.19.0*" find: /dev/.lxd-mounts: Permission denied find: /sys/kernel/tracing: Permission denied find: /sys/kernel/debug: Permission denied find: /sys/fs/pstore: Permission denied find: /proc/sys/fs/binfmt_misc: Permission denied find: /proc/tty/driver: Permission denied alpine-01:~# alpine-01:~# # >> Nichts zu finden! alpine-01:~# alpine-01:~# alpine-01:~# find / -name "*aba84e74-e806-437b-a1ca-e28e4e93b7b5*" find: /dev/.lxd-mounts: Permission denied find: /sys/kernel/tracing: Permission denied find: /sys/kernel/debug: Permission denied find: /sys/fs/pstore: Permission denied find: /proc/sys/fs/binfmt_misc: Permission denied find: /proc/tty/driver: Permission denied alpine-01:~# alpine-01:~# # >> Auch nichts finden! alpine-01:~# alpine-01:~# alpine-01:~# du -sh / du: can't open '/dev/.lxd-mounts': Permission denied du: can't open '/sys/kernel/tracing': Permission denied du: can't open '/sys/kernel/debug': Permission denied du: can't open '/sys/fs/pstore': Permission denied du: can't open '/proc/sys/fs/binfmt_misc': Permission denied du: can't open '/proc/tty/driver': Permission denied 19.6M / alpine-01:~# alpine-01:~# # >> Sehr kleines "rootfs", viele Lesefehler in /proc = typisch Container. alpine-01:~# alpine-01:~# alpine-01:~# alpine-01:~# ### Und vor derselbe Kernel: alpine-01:~# uname -r 4.19.0-13-amd64 alpine-01:~# exit alpine-01:~$ exit Connection to 10.234.55.51 closed. tux@deb10:~$ uname -r 4.19.0-13-amd64 tux@deb10:~$ tux@deb10:~$ tux@deb10:~$ lxc list +-----------+---------+---------------------+----------------------------------------------+-----------+-----------+ | NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS | +-----------+---------+---------------------+----------------------------------------------+-----------+-----------+ | alpine-01 | RUNNING | 10.234.55.51 (eth0) | fd42:13d0:a9c9:ecdb:216:3eff:fec8:727 (eth0) | CONTAINER | 0 | +-----------+---------+---------------------+----------------------------------------------+-----------+-----------+ tux@deb10:~$ tux@deb10:~$ /bin/su - Passwort: root@deb10:~# root@deb10:~# find /var -cmin -3 /var/snap/lxd/common/lxd/storage-pools/default/containers/alpine-01/rootfs/var/log/messages /var/snap/lxd/common/lxd/storage-pools/default/containers/alpine-01/rootfs/root/.ash_history /var/snap/lxd/common/lxd/storage-pools/default/containers/alpine-01/rootfs/home/tux/.ash_history root@deb10:~# root@deb10:~# root@deb10:~# find /var -name nur-ein-test /var/tmp/nur-ein-test root@deb10:~# root@deb10:~# find /var -name nur-ein-test -delete root@deb10:~# root@deb10:~# find /var -name nur-ein-test root@deb10:~# root@deb10:~# # >> ACHTUNG: Die Aktion '-delete' löscht OHNE Rückfrage!! root@deb10:~# root@deb10:~# root@deb10:~# root@deb10:~# ## Weshalb wir vorhin mit '-cmin -3' gesucht haben: root@deb10:~# du -sh /var/snap/lxd/common/lxd/storage-pools/default/containers/alpine-01/rootfs/ 20M /var/snap/lxd/common/lxd/storage-pools/default/containers/alpine-01/rootfs/ root@deb10:~# root@deb10:~# du -sh /var/snap/lxd/common/lxd/storage-pools/default/containers/alpine-01/rootfs/* | sort -h 4,0K /var/snap/lxd/common/lxd/storage-pools/default/containers/alpine-01/rootfs/dev 4,0K /var/snap/lxd/common/lxd/storage-pools/default/containers/alpine-01/rootfs/mnt 4,0K /var/snap/lxd/common/lxd/storage-pools/default/containers/alpine-01/rootfs/opt 4,0K /var/snap/lxd/common/lxd/storage-pools/default/containers/alpine-01/rootfs/proc 4,0K /var/snap/lxd/common/lxd/storage-pools/default/containers/alpine-01/rootfs/run 4,0K /var/snap/lxd/common/lxd/storage-pools/default/containers/alpine-01/rootfs/srv 4,0K /var/snap/lxd/common/lxd/storage-pools/default/containers/alpine-01/rootfs/sys 8,0K /var/snap/lxd/common/lxd/storage-pools/default/containers/alpine-01/rootfs/root 12K /var/snap/lxd/common/lxd/storage-pools/default/containers/alpine-01/rootfs/home 12K /var/snap/lxd/common/lxd/storage-pools/default/containers/alpine-01/rootfs/tmp 16K /var/snap/lxd/common/lxd/storage-pools/default/containers/alpine-01/rootfs/media 816K /var/snap/lxd/common/lxd/storage-pools/default/containers/alpine-01/rootfs/sbin 1,2M /var/snap/lxd/common/lxd/storage-pools/default/containers/alpine-01/rootfs/etc 1,6M /var/snap/lxd/common/lxd/storage-pools/default/containers/alpine-01/rootfs/bin 1,8M /var/snap/lxd/common/lxd/storage-pools/default/containers/alpine-01/rootfs/var 5,3M /var/snap/lxd/common/lxd/storage-pools/default/containers/alpine-01/rootfs/lib 8,8M /var/snap/lxd/common/lxd/storage-pools/default/containers/alpine-01/rootfs/usr root@deb10:~# root@deb10:~# root@deb10:~# exit Abgemeldet tux@deb10:~$ tux@deb10:~$ lxc list +-----------+---------+---------------------+----------------------------------------------+-----------+-----------+ | NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS | +-----------+---------+---------------------+----------------------------------------------+-----------+-----------+ | alpine-01 | RUNNING | 10.234.55.51 (eth0) | fd42:13d0:a9c9:ecdb:216:3eff:fec8:727 (eth0) | CONTAINER | 0 | +-----------+---------+---------------------+----------------------------------------------+-----------+-----------+ tux@deb10:~$ tux@deb10:~$ tux@deb10:~$ tux@deb10:~$ # Nach weiteren Linux-Images suchen: tux@deb10:~$ tux@deb10:~$ lxc image list images: | grep -i suse | head | opensuse/15.1 (3 more) | 03d48b5d07fa | yes | Opensuse 15.1 amd64 (20210127_04:20) | x86_64 | VIRTUAL-MACHINE | 205.06MB | Jan 27, 2021 at 12:00am (UTC) | | opensuse/15.1 (3 more) | 4e43d94ca368 | yes | Opensuse 15.1 amd64 (20210127_04:20) | x86_64 | CONTAINER | 42.59MB | Jan 27, 2021 at 12:00am (UTC) | | opensuse/15.1/arm64 (1 more) | 6fcf9e37fe32 | yes | Opensuse 15.1 arm64 (20210127_04:20) | aarch64 | VIRTUAL-MACHINE | 202.38MB | Jan 27, 2021 at 12:00am (UTC) | | opensuse/15.1/arm64 (1 more) | a86341f0bf31 | yes | Opensuse 15.1 arm64 (20210127_04:20) | aarch64 | CONTAINER | 41.06MB | Jan 27, 2021 at 12:00am (UTC) | | opensuse/15.1/cloud (1 more) | 9796b6b30f27 | yes | Opensuse 15.1 amd64 (20210127_04:20) | x86_64 | CONTAINER | 67.60MB | Jan 27, 2021 at 12:00am (UTC) | | opensuse/15.1/cloud (1 more) | df8e0c7a2676 | yes | Opensuse 15.1 amd64 (20210127_04:20) | x86_64 | VIRTUAL-MACHINE | 248.44MB | Jan 27, 2021 at 12:00am (UTC) | | opensuse/15.1/cloud/arm64 | 988e8c46c27b | yes | Opensuse 15.1 arm64 (20210127_04:20) | aarch64 | VIRTUAL-MACHINE | 240.50MB | Jan 27, 2021 at 12:00am (UTC) | | opensuse/15.1/cloud/arm64 | aa86948ed927 | yes | Opensuse 15.1 arm64 (20210127_04:20) | aarch64 | CONTAINER | 65.61MB | Jan 27, 2021 at 12:00am (UTC) | | opensuse/15.1/cloud/ppc64el | 584fb774d1b1 | yes | Opensuse 15.1 ppc64el (20210127_04:20) | ppc64le | CONTAINER | 71.28MB | Jan 27, 2021 at 12:00am (UTC) | | opensuse/15.1/ppc64el (1 more) | 577499a5770b | yes | Opensuse 15.1 ppc64el (20210127_04:20) | ppc64le | CONTAINER | 45.41MB | Jan 27, 2021 at 12:00am (UTC) | tux@deb10:~$ tux@deb10:~$ tux@deb10:~$ # Nach weiteren Linux-Images suchen: tux@deb10:~$ tux@deb10:~$ lxc image list images: | grep -i suse | head tux@deb10:~$ lxc launch images:opensuse/15.1 suse-01 Creating suse-01 Starting suse-01 tux@deb10:~$ tux@deb10:~$ tux@deb10:~$ lxc list +-----------+---------+----------------------+------------------------------------------------+-----------+-----------+ | NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS | +-----------+---------+----------------------+------------------------------------------------+-----------+-----------+ | alpine-01 | RUNNING | 10.234.55.51 (eth0) | fd42:13d0:a9c9:ecdb:216:3eff:fec8:727 (eth0) | CONTAINER | 0 | +-----------+---------+----------------------+------------------------------------------------+-----------+-----------+ | suse-01 | RUNNING | 10.234.55.206 (eth0) | fd42:13d0:a9c9:ecdb:f965:db4f:da1c:8b56 (eth0) | CONTAINER | 0 | | | | | fd42:13d0:a9c9:ecdb:216:3eff:fe4e:747a (eth0) | | | +-----------+---------+----------------------+------------------------------------------------+-----------+-----------+ tux@deb10:~$ tux@deb10:~$ lxc exec suse-01 bash suse-01:~ # suse-01:~ # suse-01:~ # du -sh / du: cannot read directory '/dev/.lxd-mounts': Permission denied du: cannot read directory '/sys/kernel/tracing': Permission denied du: cannot read directory '/sys/kernel/debug': Permission denied du: cannot read directory '/sys/fs/pstore': Permission denied du: cannot read directory '/proc/sys/fs/binfmt_misc': Permission denied du: cannot read directory '/proc/tty/driver': Permission denied du: cannot access '/proc/1669/task/1669/fd/4': No such file or directory du: cannot access '/proc/1669/task/1669/fdinfo/4': No such file or directory du: cannot access '/proc/1669/fd/3': No such file or directory du: cannot access '/proc/1669/fdinfo/3': No such file or directory 182M / suse-01:~ # suse-01:~ # suse-01:~ # passwd root New password: BAD PASSWORD: it is too short BAD PASSWORD: is too simple Retype new password: passwd: password updated successfully suse-01:~ # suse-01:~ # useradd -m tux Group 'mail' not found. Creating the user mailbox file with 0600 mode. suse-01:~ # suse-01:~ # passwd tux New password: BAD PASSWORD: it is WAY too short BAD PASSWORD: is too simple Retype new password: passwd: password updated successfully suse-01:~ # suse-01:~ # suse-01:~ # suse-01:~ # ## Auf diese RPM-basierten Distribution nach 'ssh'-Paketen fahnden: suse-01:~ # rpm -qa | wc -l 183 suse-01:~ # suse-01:~ # rpm -qa | grep ssh libssh4-0.8.7-lp151.2.12.1.x86_64 suse-01:~ # suse-01:~ # suse-01:~ # ## Paketquellen auffrischen (= 'apt-get update'): suse-01:~ # zypper refresh Retrieving repository 'Non-OSS Repository' metadata ............................................................[done] Building repository 'Non-OSS Repository' cache .................................................................[done] Retrieving repository 'Main Repository' metadata ...............................................................[done] Building repository 'Main Repository' cache ....................................................................[done] Retrieving repository 'Main Update Repository' metadata ........................................................[done] Building repository 'Main Update Repository' cache .............................................................[done] Retrieving repository 'Update Repository (Non-Oss)' metadata ...................................................[done] Building repository 'Update Repository (Non-Oss)' cache ........................................................[done] All repositories have been refreshed. suse-01:~ # suse-01:~ # yast bash: yast: command not found suse-01:~ # suse-01:~ # zypper se openssh Loading repository data... Reading installed packages... S | Name | Summary | Type --+---------------------------+---------------------------------------------------------+----------- | lxqt-openssh-askpass | Openssh password tool | package | lxqt-openssh-askpass-lang | Languages for package lxqt-openssh-askpass | package | openssh | Secure Shell Client and Server (Remote Login Program) | package | openssh | Secure Shell Client and Server (Remote Login Program) | srcpackage | openssh-askpass | A passphrase dialog for OpenSSH and the X Window System | package | openssh-askpass-gnome | A GNOME-Based Passphrase Dialog for OpenSSH | package | openssh-askpass-gnome | A GNOME-Based Passphrase Dialog for OpenSSH | srcpackage | openssh-cavs | OpenSSH FIPS cryptomodule CAVS tests | package | openssh-fips | OpenSSH FIPS cryptomodule HMACs | package | openssh-helpers | OpenSSH AuthorizedKeysCommand helpers | package suse-01:~ # suse-01:~ # suse-01:~ # zypper in openssh Loading repository data... Reading installed packages... Resolving package dependencies... The following 2 NEW packages are going to be installed: libedit0 openssh 2 new packages to install. Overall download size: 1.1 MiB. Already cached: 0 B. After the operation, additional 5.7 MiB will be used. Continue? [y/n/v/...? shows all options] (y): y Retrieving package libedit0-3.1.snap20150325-lp151.3.3.x86_64 (1/2), 94.3 KiB (222.2 KiB unpacked) Retrieving: libedit0-3.1.snap20150325-lp151.3.3.x86_64.rpm .......................................[done (214.3 KiB/s)] Retrieving package openssh-7.9p1-lp151.4.18.1.x86_64 (2/2), 995.9 KiB ( 5.5 MiB unpacked) Retrieving: openssh-7.9p1-lp151.4.18.1.x86_64.rpm ..............................................................[done] Checking for file conflicts: ...................................................................................[done] (1/2) Installing: libedit0-3.1.snap20150325-lp151.3.3.x86_64 ...................................................[done] (2/2) Installing: openssh-7.9p1-lp151.4.18.1.x86_64 ............................................................[done] Additional rpm output: Updating /etc/sysconfig/ssh ... setting /etc/ssh/sshd_config to root:root 0640. (wrong permissions 0600) suse-01:~ # suse-01:~ # suse-01:~ # systemctl start sshd suse-01:~ # suse-01:~ # suse-01:~ # systemctl status sshd ● sshd.service - OpenSSH Daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; disabled; vendor preset: disabled) Active: active (running) since Wed 2021-01-27 13:46:41 UTC; 23s ago Process: 2194 ExecStartPre=/usr/sbin/sshd -t $SSHD_OPTS (code=exited, status=0/SUCCESS) Process: 2192 ExecStartPre=/usr/sbin/sshd-gen-keys-start (code=exited, status=0/SUCCESS) Main PID: 2195 (sshd) Tasks: 1 CGroup: /system.slice/sshd.service └─2195 /usr/sbin/sshd -D Jan 27 13:46:40 suse-01 systemd[1]: Starting OpenSSH Daemon... Jan 27 13:46:40 suse-01 sshd-gen-keys-start[2192]: Checking for missing server keys in /etc/ssh Jan 27 13:46:41 suse-01 sshd-gen-keys-start[2192]: ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519 Jan 27 13:46:41 suse-01 systemd[1]: sshd.service: Failed to set invocation ID on control group /system.slice/s shd.service, ignoring: Operation not permitted Jan 27 13:46:41 suse-01 systemd[1]: sshd.service: Failed to set invocation ID on control group /system.slice/s shd.service, ignoring: Operation not permitted Jan 27 13:46:41 suse-01 sshd[2195]: Server listening on 0.0.0.0 port 22. Jan 27 13:46:41 suse-01 sshd[2195]: Server listening on :: port 22. Jan 27 13:46:41 suse-01 systemd[1]: Started OpenSSH Daemon. suse-01:~ # suse-01:~ # suse-01:~ # systemctl enable sshd Created symlink /etc/systemd/system/multi-user.target.wants/sshd.service → /usr/lib/systemd/system/sshd.service. suse-01:~ # suse-01:~ # suse-01:~ # systemctl status sshd ● sshd.service - OpenSSH Daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2021-01-27 13:46:41 UTC; 1min 3s ago Main PID: 2195 (sshd) Tasks: 1 CGroup: /system.slice/sshd.service └─2195 /usr/sbin/sshd -D Jan 27 13:46:40 suse-01 systemd[1]: Starting OpenSSH Daemon... Jan 27 13:46:40 suse-01 sshd-gen-keys-start[2192]: Checking for missing server keys in /etc/ssh Jan 27 13:46:41 suse-01 sshd-gen-keys-start[2192]: ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519 Jan 27 13:46:41 suse-01 systemd[1]: sshd.service: Failed to set invocation ID on control group /system.slice/s shd.service, ignoring: Operation not permitted Jan 27 13:46:41 suse-01 systemd[1]: sshd.service: Failed to set invocation ID on control group /system.slice/s shd.service, ignoring: Operation not permitted Jan 27 13:46:41 suse-01 sshd[2195]: Server listening on 0.0.0.0 port 22. Jan 27 13:46:41 suse-01 sshd[2195]: Server listening on :: port 22. Jan 27 13:46:41 suse-01 systemd[1]: Started OpenSSH Daemon. Jan 27 13:47:38 suse-01 systemd[1]: sshd.service: Failed to set invocation ID on control group /system.slice/s shd.service, ignoring: Operation not permitted suse-01:~ # suse-01:~ # suse-01:~ # suse-01:~ # history 1 2021-01-27 13:40:06 du -sh / 2 2021-01-27 13:40:25 passwd root 3 2021-01-27 13:40:46 useradd -m tux 4 2021-01-27 13:40:55 passwd tux 5 2021-01-27 13:41:45 ## Auf diese RPM-basierten Distribution nach 'ssh'-Paketen fahnden: 6 2021-01-27 13:42:19 rpm -qa | wc -l 7 2021-01-27 13:42:24 rpm -qa | grep ssh 8 2021-01-27 13:42:50 ## Paketquellen auffrischen (= 'apt-get update'): 9 2021-01-27 13:43:01 zypper refresh 10 2021-01-27 13:43:55 yast 11 2021-01-27 13:44:18 zypper se openssh 12 2021-01-27 13:44:46 zypper in openssh 13 2021-01-27 13:46:32 systemctl status sshd 14 2021-01-27 13:46:40 systemctl start sshd 15 2021-01-27 13:47:05 systemctl status sshd 16 2021-01-27 13:47:37 systemctl enable sshd 17 2021-01-27 13:47:44 systemctl status sshd 18 2021-01-27 13:48:27 history suse-01:~ # suse-01:~ # suse-01:~ # exit exit tux@deb10:~$ tux@deb10:~$ lxc list +-----------+---------+----------------------+------------------------------------------------+-----------+-----------+ | NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS | +-----------+---------+----------------------+------------------------------------------------+-----------+-----------+ | alpine-01 | RUNNING | 10.234.55.51 (eth0) | fd42:13d0:a9c9:ecdb:216:3eff:fec8:727 (eth0) | CONTAINER | 0 | +-----------+---------+----------------------+------------------------------------------------+-----------+-----------+ | suse-01 | RUNNING | 10.234.55.206 (eth0) | fd42:13d0:a9c9:ecdb:f965:db4f:da1c:8b56 (eth0) | CONTAINER | 0 | | | | | fd42:13d0:a9c9:ecdb:216:3eff:fe4e:747a (eth0) | | | +-----------+---------+----------------------+------------------------------------------------+-----------+-----------+ tux@deb10:~$ tux@deb10:~$ tux@deb10:~$ ## Anstelle von "lxc exec suse-01 bash" nun via 'ssh' in den Container gehen: tux@deb10:~$ ssh tux@10.234.55.206 The authenticity of host '10.234.55.206 (10.234.55.206)' can't be established. ECDSA key fingerprint is SHA256:2i5OSJ1AghYCU+OCG8QbALfN/9grA6eAgecySd7huvs. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '10.234.55.206' (ECDSA) to the list of known hosts. Password: Have a lot of fun... tux@suse-01:~> tux@suse-01:~> cal January 2021 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 tux@suse-01:~> tux@suse-01:~> date Wed Jan 27 13:50:21 UTC 2021 tux@suse-01:~> tux@suse-01:~> Have a lot of fun...