curl

Dies ist eine alte Version des Dokuments!


CURL

https://curl.haxx.se/docs/httpscripting.html

https://curl.haxx.se/docs/manual.html
Request/Response Information

thommie@locutus:~> curl -iv –head locutus.netzwissen.loc:3128 https://www.netzwissen.de
* Rebuilt URL to: locutus.netzwissen.loc:3128/ * Trying 192.168.72.1… * TCP_NODELAY set * Connected to locutus.netzwissen.loc (192.168.72.1) port 3128 (#0)> HEAD / HTTP/1.1> Host: locutus.netzwissen.loc:3128> User-Agent: curl/7.60.0> Accept: */*> HEAD / HTTP/1.1> Host: www.netzwissen.de> User-Agent: curl/7.60.0> Accept: */*>

Geht auch mit https für selbst signierte Zertifikate, dann -k dahintersetzen, curl –trace-ascii [filename] -k :

== Info: Hostname was NOT found in DNS cache
== Info: Trying 5.9.175.13…
== Info: Connected to www.netzwissen.de (5.9.175.13) port 443 (#0)
== Info: successfully set certificate verify locations:
== Info: CAfile: none
CApath: /etc/ssl/certs/
== Info: SSLv3, TLS Unknown, Unknown (22):
⇒ Send SSL data, 5 bytes (0x5)
0000: …..
== Info: SSLv3, TLS handshake, Client hello (1):
⇒ Send SSL data, 194 bytes (0xc2)
0000: ……=hf.E^..<….4…n.[…..g..xQR5..6.,.$.+.#.0.(…/.'…..
0040: k.9…..g.3.E…=.5…..<./.A….._………www.netzwissen.de
0080: ………………………. ……………………………..
00c0: ..
== Info: SSLv2, Unknown (22):
⇐ Recv SSL data, 5 bytes (0x5)
0000: ….b
== Info: SSLv3, TLS handshake, Server hello (2):
⇐ Recv SSL data, 98 bytes (0x62)
0000: …^…..#Z}Hk,..DzO..*…b.A…….|. .!.0.Z!….~y.H….J{..{.
0040: l$ …i./…………………….
== Info: SSLv2, Unknown (22):
⇐ Recv SSL data, 5 bytes (0x5)
0000: …..
== Info: SSLv3, TLS handshake, CERT (11):
⇐ Recv SSL data, 2476 bytes (0x9ac)
[…]
⇒ Send SSL data, 5 bytes (0x5)
0000: …..
== Info: SSLv3, TLS change cipher, Client hello (1):
⇒ Send SSL data, 1 bytes (0x1)
0000: .
== Info: SSLv2, Unknown (22):
⇒ Send SSL data, 5 bytes (0x5)
0000: ….(
== Info: SSLv3, TLS handshake, Finished (20):
⇒ Send SSL data, 16 bytes (0x10)
0000: …..Kr.F.s…|?
== Info: SSLv2, Unknown (20):
⇐ Recv SSL data, 5 bytes (0x5)
0000: …..
== Info: SSLv3, TLS change cipher, Client hello (1):
⇐ Recv SSL data, 1 bytes (0x1)
0000: .
== Info: SSLv2, Unknown (22):
⇐ Recv SSL data, 5 bytes (0x5)
0000: ….(
== Info: SSLv3, TLS handshake, Finished (20):
⇐ Recv SSL data, 16 bytes (0x10)
0000: ……x7..m….3
== Info: SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
== Info: Server certificate:
== Info: subject: CN= www.netzwissen.de
== Info: start date: 2018-01-08 01:45:24 GMT
== Info: expire date: 2018-04-08 01:45:24 GMT
== Info: subjectAltName: www.netzwissen.de matched
== Info: issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
== Info: SSL certificate verify ok.
== Info: SSLv2, Unknown (23):
⇒ Send SSL data, 5 bytes (0x5)
0000: ….r
⇒ Send header, 90 bytes (0x5a)
0000: GET /owncloud/ HTTP/1.1
0019: User-Agent: curl/7.37.0
0032: Host: www.netzwissen.de
004b: Accept: */*
0058:
== Info: SSLv2, Unknown (23):
⇐ Recv SSL data, 5 bytes (0x5)
0000: ….$
⇐ Recv header, 20 bytes (0x14)
0000: HTTP/1.1 302 Found
⇐ Recv header, 37 bytes (0x25)
0000: Date: Mon, 15 Jan 2018 12:57:16 GMT
== Info: Server Apache is not blacklisted
⇐ Recv header, 16 bytes (0x10)
0000: Server: Apache
⇐ Recv header, 64 bytes (0x40)
0000: Strict-Transport-Security: max-age=31536000; includeSubDomains
⇐ Recv header, 80 bytes (0x50)
0000: Set-Cookie: 52401d632a450=d41rivsekv3g0u91lrberil374; path=/ownc
0040: loud; HttpOnly
⇐ Recv header, 40 bytes (0x28)
0000: Expires: Thu, 19 Nov 1981 08:52:00 GMT
⇐ Recv header, 52 bytes (0x34)
0000: Cache-Control: no-store, no-cache, must-revalidate
⇐ Recv header, 18 bytes (0x12)
0000: Pragma: no-cache
⇐ Recv header, 203 bytes (0xcb)
0000: Set-Cookie: oc_sessionPassphrase=qWyjYXC7eQ7r7vVBGHXtwX9oPZlXT65
0040: rUVrDI7mbVwfURHhS3YTRdrTHEcUVDCzsbvI%2B1RAz%2FGGpqbgdTeewiFIn8Wd
0080: zszvm2mVyLgAPrYyi%2FNm6E3nB5LrtN0HhtWyF; path=/owncloud; secure;
00c0: HttpOnly
⇐ Recv header, 199 bytes (0xc7)
0000: Content-Security-Policy: default-src 'self'; script-src 'self' '
0040: unsafe-eval'; style-src 'self' 'unsafe-inline'; frame-src *; img
0080: -src * data: blob:; font-src 'self' data:; media-src *; connect-
00c0: src *
⇐ Recv header, 62 bytes (0x3e)
0000: Location: https://www.netzwissen.de/owncloud/index.php/login
⇐ Recv header, 33 bytes (0x21)
0000: X-Content-Type-Options: nosniff
⇐ Recv header, 33 bytes (0x21)
0000: X-XSS-Protection: 1; mode=block
⇐ Recv header, 20 bytes (0x14)
0000: X-Robots-Tag: none
⇐ Recv header, 29 bytes (0x1d)
0000: X-Frame-Options: SAMEORIGIN
⇐ Recv header, 28 bytes (0x1c)
0000: X-Download-Options: noopen
⇐ Recv header, 41 bytes (0x29)
0000: X-Permitted-Cross-Domain-Policies: none
⇐ Recv header, 19 bytes (0x13)
0000: Content-Length: 0
⇐ Recv header, 40 bytes (0x28)
0000: Content-Type: text/html; charset=UTF-8
⇐ Recv header, 2 bytes (0x2)
0000:
== Info: Connection #0 to host www.netzwissen.de left intact

Mit Zeit Informationen

14:03:49.807389 == Info: Hostname was NOT found in DNS cache14:03:49.811593 == Info: Trying 5.9.175.13… 14:03:49.836058 == Info: Connected to www.netzwissen.de (5.9.175.13) port 443 (#0)
14:03:49.836321 == Info: successfully set certificate verify locations:
14:03:49.836328 == Info: CAfile: none
CApath: /etc/ssl/certs/
14:03:49.836400 == Info: SSLv3, TLS Unknown, Unknown (22):
14:03:49.836406 ⇒ Send SSL data, 5 bytes (0x5)
0000: …..
14:03:49.836431 == Info: SSLv3, TLS handshake, Client hello (1):
14:03:49.836441 ⇒ Send SSL data, 194 bytes (0xc2)
0000: ………?..Nu……a….W….a&.`I"….6.,.$.+.#.0.(…/.'…..
0040: k.9…..g.3.E…=.5…..<./.A….._………www.netzwissen.de
0080: ………………………. ……………………………..
00c0: ..
14:03:49.863253 == Info: SSLv2, Unknown (22):
14:03:49.863266 ⇐ Recv SSL data, 5 bytes (0x5)
0000: ….b
14:03:49.863299 == Info: SSLv3, TLS handshake, Server hello (2):
14:03:49.863306 ⇐ Recv SSL data, 98 bytes (0x62)
0000: …^…?……..f."..3k……..a.}G2.. B(-.3P…wJ.i.N….Y…..
0040: .C.~&…/…………………….

Alle Kommandozeilen Befehle als User "vbox" (mit sudo) durchführen, nicht als root. Grund: Beim Starten einer vm als Root werden VM-Daten mit root Rechten angelegt, die anschliessend für den vbox User nicht mehr editierbar sind. Das führt zu Fehlermeldungen und nicht startbaren VMs, u.a. in der phpvirtualbox Oberfläche.
Laufende VMs und Platten auflisten
vboxmanage list vms "TestVM" {ad1a008e-52ed-4f55-9642-3fcd328f1910} "www.netzwissen.de" {9eb328b0-ff15-4453-b17e-fad1e10029c7}

Details einer bestimmten VM zeigen:
vboxmanage showvminfo www.netzwissen.de

Festplatten auflisten (alle VMs)

VBoxManage list hdds

IBAN: DE41611500200008594082 / BIC: ESSLDE66XXX

/etc/myssl/dh2048.pem – using compiled-in defaul

FILE=`mktemp` ; openssl dhparam 2048 -out $FILE && mv -f $FILE /etc/myssl/dh2048.pem >/dev/null 2>&

openssl dhparm -out /etc/myssl/dh2048.pem 2048

warning: connect to Milter service unix:/var/run/amavis/amavisd-milter.sock: No such file or directory

Details einer bestimmten HDD auflisten:
vbox@tarapiroe:/mnt/vbox/VirtualBox VMs/miteinander-esslingen.de$ VBoxManage showmediuminfo disk fluechtlinge-esslingen.de2b.vdi UUID: 252b4e07-1eb4-4f41-b256-7655b2b37788 Parent UUID: base State: created Type: normal (base) Location: /mnt/vbox/VirtualBox VMs/miteinander-esslingen.de/fluechtlinge-esslingen.de2b.vdi Storage format: VDI Format variant: dynamic default Capacity: 20480 MBytes Size on disk: 13590 MBytes Encryption: disabled In use by VMs: miteinander-esslingen.de (UUID: a884b3e1-ee26-4122-9738-de3c8ee7008a)

Festplatten Registrierung aufheben
VBoxManage closemedium [disk|dvd|floppy] [–delete]
VMs starten und beenden

Runterfahren zum Backup (entspricht einem Freeze, kein "echtes" Runterfahren). Keine Änderungen an der VM Konfiguration möglich.

vboxmanage controlvm [vm name] savestate


Pausieren

VBoxManage controlvm <vm> pause


Weitermachen

VBoxManage controlvm <vm> resume


Harter Reset

VBoxManage controlvm <vm> reset


Normaler Shutdown (echtes Runterfahren ohne savestate)

VBoxManage controlvm <vm> acpipowerbutton


Harter Shutdown (Strom weg):

VBoxManage controlvm <vm> poweroff


Starten (ohne GUI)

vboxmanage startvm [vm name] –type headless


VM Autostart
vboxmanage modifyvm TestVM –autostart-enabled on
*.vdi mounten

siehe auch https://www.schnatterente.net/software/virtualbox-vdi-image-in-linux-mounten

Wir brauchen ein VirtualBox Disk Image (VDI), fdisk, QEMU und einen Linux-Kernel, der Network Block Devices (NBD) sowie Virtualisierung (Kernel-based Virtual Machine = KVM) unterstützt.

Ggf. QEMU nachinstallieren mit
apt install qemu-system-x86

Modul in den Kernel landen laden

modprobe nbd


Danach das vdi Image reinladen

qemu-nbd -c /dev/nbd0 /mnt/vbox/VirtualBox VMs/www.netzwissen.de/www.netzwissen.de.vdi


Mit fdisk sieht man die Partitionstabelle
# fdisk -l /dev/nbd0

Wir sehen, dass fdisk alle vorhandenen Partitionen auflistet und ihnen auch ein Gerät zuordnet. Das Verwirrende ist nun, dass es die Geräte-Dateien /dev/nbd0pX nicht gibt. Wir haben nur Zugriff auf /dev/nbd0. Um dennoch eine Partition einhängen zu können, behelfen wir uns daher mit einem Trick. Wir geben beim Mounten den Beginn der jeweiligen Partition als Offset an und benutzen als Gerät einfach die Festplatte /dev/nbd0 (und eben nicht die spezifische Partition).
mount -o offset=1048576 /dev/nbd0 /mnt/vdi/

Damit ist die erste Partition der Festplatte in /mnt/vdi/ eingehängt. Nun fragt ihr euch sicher, woher die Zahl 1048576 kommt. Dabei handelt es sich um das Produkt der Blockgröße (512 Byte) und des Anfangs der zu mountenden Partition auf der Festplatte (2048). Man muss also den Offset richtig setzen:
fdisk -l /dev/nbd0 Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x000e0051 Device Boot Start End Sectors Size Id Type /dev/nbd0p1 * 2048 499711 497664 243M 83 Linux /dev/nbd0p2 501758 117438463 116936706 55.8G 5 Extended /dev/nbd0p5 501760 117438463 116936704 55.8G 8e Linux LVM

Mount z.B. für die dritte Partition mit -o (512 x 501760) :

mount -o offset=256901120 -t ext4 /dev/nbd0 /mnt/vdi1/


Nach Abschluss aller Arbeiten über das Block Device dieses wieder abmelden:
root@tarapiroe /mnt # qemu-nbd -d /dev/nbd0 /dev/nbd0 disconnected root@tarapiroe /mnt # qemu-nbd -d /dev/nbd1 /dev/nbd1 disconnected

Mounten einer LVM Partition

Mit pvs die Volume Groups anzeigen:
root@tarapiroe /home/thommie # pvs PV VG Fmt Attr PSize PFree /dev/loop1 www2 lvm2 a– 194.00g 138.24g /dev/md3 data1 lvm2 a– 2.66t 1.39t

Danach mit lvdisplay den Namen des logical volumes ermitteln:
root@tarapiroe /home/thommie # lvdisplay /dev/www2 — Logical volume — LV Path /dev/www2/root LV Name root VG Name www2 LV UUID EuK1p3-7Q76-URFe-v6eX-HS8M-02xc-TTNCqR LV Write Access read/write LV Creation host, time , LV Status available # open 0 LV Size 54.76 GiB Current LE 14018 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:2 — Logical volume — LV Path /dev/www2/swap_1 LV Name swap_1 VG Name www2 LV UUID NwcGd9-f1Ng-MIqE-bXTC-x0dd-K69j-nVpQ3q LV Write Access read/write LV Creation host, time , LV Status available # open 0 LV Size 1.00 GiB Current LE 256 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:3

Daraus bildet sich der Mount Befehl:

root@tarapiroe /home/thommie # mount /dev/www2/root /mnt/vdi1


Danach mit umount /mnt/vdi wieder unmounten und das VDI abmelden mit
# qemu-nbd -d /dev/nbd0
Umwandeln einer *.vdi Platte ins RAW Format
VBoxManage clonehd –format RAW /mnt/backup/vbox/vboxsnapshot/VirtualBox VMs/miteinander-esslingen.de/fluechtlinge-esslingen.de.vdi /home/thommie/miteinander-esslingen.img

Achtung: ggf. voher die Originalgrösse mit VBoxManage showhdinfo [your vdi file] prüfen.

Danach mounten
mount -t ext3 -o loop,rw ./ubuntu.img /mnt
Virtuelle Platten verkleinern & vergrößern

Alle Operationen nur mit hart abgeschalteter VM (acpipowerbutton), savestate reicht nicht.

Achtung: resize geht nur, wenn die virtuelle vdi Datei in format variant "dynamic default" ist. Falls es eine "fixed variant" ist, erst mit clonehd umkopieren:

vboxmanage clonehd fluechtlinge-esslingen.de.vdi fluechtlinge-esslingen.deb.vdi


Verkleinern

Virtuelle Platten mit dynamischer Grösse werden mit der Zeit grösser. Aber es gibt keinen Mechanismus, um Plattenplatz, der innerhalb der der VM gelöscht wurde, wieder an den Host zurück zu geben. Unterm Strich sind die virtuellen Platten real größer als innerhalb der VM. Mit diesem Mechanismus lässt sich eine virtuelle Platte wieder verkleinern:

zerofree in der VM installieren
in der VM die Partition mit read only mounten, z.B.:

mount -n -o remount,ro -t ext4 /dev/sdb1 /

Dann mit zerofree -v /dev/sdb1 unbenutzte Bereiche der Platte mit Nullen beschreiben
VM wieder runterfahren und auf dem Host die reale Plattendatei (*.vdi) verkleinern

VBoxManage modifyhd –compact /path/to/virtualboximage.vdi

Für die Root Partition die VM neu starten und den Rescue Mode wählen (um die Root Partition freizugeben). Danach wie oben.
Vergrößern

VM mit acpipowerbutton runterfahren, dann aktuellen Status der Platte zeigen lassen
vboxmanage showhdinfo /mnt/vbox/VirtualBox VMs/www.netzwissen.de/www.netzwissen.de2.vdi

…. zeigt die Informationen zu einer virtuellen Platte
vbox@tarapiroe:/home/thommie$ vboxmanage showhdinfo /mnt/vbox/VirtualBox VMs/www.netzwissen.de/www.netzwissen.de2.vdi UUID: ce28b063-c7f7-429f-9c81-6163489c913a Parent UUID: base State: created Type: normal (base) Location: /mnt/vbox/VirtualBox VMs/www.netzwissen.de/www.netzwissen.de2.vdi Storage format: VDI Format variant: dynamic default Capacity: 61440 MBytes Size on disk: 40804 MBytes Encryption: disabled In use by VMs: www.netzwissen.de (UUID: 9eb328b0-ff15-4453-b17e-fad1e10029c7)

Platte umkopieren, falls "format variant = fixed"

vbox@tarapiroe:/mnt/vbox/VirtualBox VMs/miteinander-esslingen.de$ vboxmanage clonehd fluechtlinge-esslingen.de.vdi fluechtlinge-esslingen.dec.vdi


Jetzt sollte es einen vergrößerbare variant sein:

Location: /mnt/vbox/VirtualBox VMs/miteinander-esslingen.de/fluechtlinge-esslingen.dec.vdi
Storage format: VDI
Format variant: dynamic default


Dann resize der *.vdi, wobei die Größe in MB angegeben wird, 15G = 15,360MB
vboxmanage modifymedium /mnt/vbox/VirtualBox VMs/www.netzwissen.de/www.netzwissen.de2.vdi –resize 61440

Je nach Partitionierung müssen Partitionen zuerst verschoben werden, bevor man sie vergrößern kann. werden. Beispiel hier:

https://www.netzgewitter.com/2011/08/resizing-linux-partition/
Vergrössern einer virtuellen Root Partition

Loop Device auf dem Host anlegen
modprobe nbd qemu-nbd -c /dev/nbd0 fluechtlinge-esslingen.deb.vdi parted /dev/nbd0

Doku zu parted: https://www.gnu.org/software/parted/manual/parted.html

Partitionstabelle zeigen mit p. Mit "unit cyl" sieht man, wo die Partitionen genau liegen.
(parted) p Model: Unknown (unknown) Disk /dev/nbd0: 12.9GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 6442MB 6441MB primary ext4 boot 2 6443MB 8589MB 2145MB extended 5 6443MB 8589MB 2145MB logical linux-swap(v1) (parted) unit cyl (parted) p Model: Unknown (unknown) Disk /dev/nbd0: 1566cyl Sector size (logical/physical): 512B/512B BIOS cylinder,head,sector geometry: 1566,255,63. Each cylinder is 8225kB. Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 0cyl 783cyl 783cyl primary ext4 boot 2 783cyl 1044cyl 260cyl extended 5 783cyl 1044cyl 260cyl logical linux-swap(v1)

Mir rm 2 löscht man die extended Partition, dann ist auch as logical volume für den swap space weg. Dann legt man den Swap am Ende der Platte neu an.

Syntax mkpart part-type [fs-type] start end, also legt
mkpart extended -61 -1 mkpart logical linux-swap -61 -1

eine Swap Partiton mit 61 x 8225kB = 492 MB an
Model: Unknown (unknown) Disk /dev/nbd0: 12885MB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1.05MB 6442MB 6441MB primary ext4 boot 2 12384MB 12877MB 493MB extended lba 5 12385MB 12877MB 492MB logical linux-swap(v1) lba

print free zeigt freien Platz an
(parted) print free Model: Unknown (unknown) Disk /dev/nbd0: 12.9GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 32.3kB 1049kB 1016kB Free Space 1 1049kB 12.8GB 12.8GB primary ext4 boot 12.8GB 12.9GB 60.8MB Free Space

Nach Änderung der Partitionstabelle muss aus dem Host heraus das Filesystem vergrößert und der gelöschte Swapspace neu angelegt werden:
resize2fs /dev/nbd0p1

Für Swap
root@tarapiroe /mnt/vbox/VirtualBox VMs/miteinander-esslingen.de # mkswap /dev/nbd1p5 Setting up swapspace version 1, size = 469 MiB (491778048 bytes) no label, UUID=f6929655-4ba7-4548-95e3-a1a32250d473
Installation Virtualbox auf Ubuntu

Virtualbox repository und key hinzufügen
vi /etc/apt/sources.list: – append: – deb http://download.virtualbox.org/virtualbox/debian precise contrib —- wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add - sudo apt-get update sudo apt-get install dkms sudo apt-get install virtualbox-4.1 –no-install-recommends VBoxManage -v ⇒ 4.1.22r80657
Extension Pack

Auflisten

sudo vboxmanage list extpacks

Download
sudo wget http://download.virtualbox.org/virtualbox/4.1.22/Oracle_VM_VirtualBox_Extension_Pack-4.1.22-80657.vbox-extpack

Als vbox: alles VMs runterfahren. Danach als root: Alte Version rauswerfen
sudo VBoxManage extpack uninstall "Oracle VM VirtualBox Extension_Pack"

Als root: neue Version installieren
sudo VBoxManage extpack install [Dateiname]

Danach vms wieder starten

Bei erster Installation:
sudo groupadd vboxusers sudo useradd -m vbox -G vboxusers sudo passwd vbox xxxxxxxxxxxxx echo "VBOXWEB_USER=vbox"> /etc/default/virtualbox sudo service vboxweb-service start sudo update-rc.d vboxweb-service defaults
PHP Virtualbox Update
sudo wget `wget -q -O - http://phpvirtualbox.googlecode.com/files/LATEST.txt` -O phpvirtualbox-latest.zip sudo unzip phpvirtualbox-*.zip sudo rm phpvirtualbox-*.zip sudo mv phpvirtualbox-* vbox sudo mv /var/www/vbox/config.php-example /var/www/vbox/config.php sudo vi /var/www/vbox/config.php – change: – var $username = 'vbox'; var $password = 'xxxxxxxxxxxxxxx'; var $location = 'http://127.0.0.1:18083/'; — chown -R www-data:www-data vbox

In /etc/init.d/vboxautostart-service bei Stop ergänzt:
stop() { [ -z "$VBOXAUTOSTART_DB" ] && exit 0 [ -z "$VBOXAUTOSTART_CONFIG" ] && exit 0

Damit uns die Kiste nicht ungesichert runterfaellt:
VBM="/usr/bin/sudo -i -u vbox /usr/bin/vboxmanage" $VBM list runningvms | sed -r 's/"(.+)".*/\1/' | while read R do echo "$R is sent to savestate!" $VBM controlvm "$R" savestate done exit 0

  • curl.1546612584.txt.gz
  • Zuletzt geändert: 05/03/2024 - 10:52
  • (Externe Bearbeitung)