Outils pour utilisateurs

Outils du site


blog

Cloud - Terrafom / OpenTofu - s3 backend

tf-lock-s3.s

#!/bin/bash
 
# Source : https://github.com/hashicorp/terraform/issues/12877
 
PROJECT_NAME="${PWD##*/}" # use current dir name
AWS_REGION="eu-west-1"
ACCOUNT_ID="$(aws sts get-caller-identity --query Account --output text)"
 
aws s3api create-bucket \
        --region "${AWS_REGION}" \
        --create-bucket-configuration LocationConstraint="${AWS_REGION}" \
        --bucket "terraform-tfstate-${ACCOUNT_ID}"
 
aws dynamodb create-table \
        --region "${AWS_REGION}" \
        --table-name terraform_locks \
        --attribute-definitions AttributeName=LockID,AttributeType=S \
        --key-schema AttributeName=LockID,KeyType=HASH \
        --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1
 
cat <<EOF > ./backend_config.tf
terraform {
  backend "s3" {
    bucket         = "terraform-tfstate-${ACCOUNT_ID}"
    key            = "${PROJECT_NAME}"
    region         = "${AWS_REGION}"
    #lock_table     = "terraform_locks"
    dynamodb_table = "terraform_locks"
  }
}
EOF
2025/03/24 15:06

Pb de taille CloneZilla

Voir Notes overlayfs CloneZilla

Voir aussi draft-sauvegarder-son-systeme-a-chaud-grace-a-mondorescue

Liens

Je dois modifier légèrement un Ghost fait avec CloneZilla. Il s'agit d'une image iso bootable contenant les données du/des disque(s)

Je crée une VM, je boot sur l'ISO.
Erreur, pas assez d'espace disque.

Je recommence, mais avec une taille de disque bien supérieur
OK

Je fais mes modifs. Je Ghost de nouveau et je génére l'iso bootable. Je test le déghost sur cette VM en bootant sur l'iso généré
OK

Je mes à dispo la nouvelle iso, pour qu'elle soit déghostée sur une machine physique. Pb, la taille des disques ne sont pas suffisant !

Il faut donc soit déghoster-modif-ghoster sur une machine ayant des disques de taille identique. Soit trouver une autre solution.

Création du Ghost

  1. boot sur l'iso Clonezilla-live
  2. Presser Entrée
  3. à la fin du Ghost cmd
Méthode 1

Lors de la création de l'ISO bootable, selectionner “Avancé” puis cocher l'option -icds

Méthode 2

Génération de l'iso bootable

Il faut modifier les fichiers sda-pt.parted, sdb-pt.parted, sdc-pt.parted (autant de fichiers que de disque)

sudo -s
loadkeys fr
 
vi /home/partimag/foobar/sda-pt.parted
vi /home/partimag/foobar/sdb-pt.parted

Ici, nous modifierons la ligne qui commence par Disk /dev/sda en remplacant la taille actuelle par la taille minimum requise.

La taille minimum requise correspond, à un chouïa près, à l'emplacement de fin de la dernière partition. Donc nous prenons dans la colonne End la dernière ligne.

Dans notre exemple c'est 976773119s.
976773119s + 1 secteur = 1258291200s

sda-pt.parted
Model: ATA WDC WD5000AAKX-0 (scsi)
Disk /dev/sda: 1258291200s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start       End         Size        Type      File system     Flags
 1      2048s       97656831s   97654784s   primary   ext4            boot
 2      97656832s   144531455s  46874624s   primary   linux-swap(v1)
 3      144533502s  976773119s  832239618s  extended
 5      144533504s  451244031s  306710528s  logical   ext4
 6      451246080s  518592511s  67346432s   logical   ext4
 8      518594560s  606562303s  87967744s   logical   ext4
 7      606564352s  976773119s  370208768s  logical   ext4
sda-pt.parted
Model: ATA WDC WD5000AAKX-0 (scsi)
Disk /dev/sda: 976773120s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start       End         Size        Type      File system     Flags
 1      2048s       97656831s   97654784s   primary   ext4            boot
 2      97656832s   144531455s  46874624s   primary   linux-swap(v1)
 3      144533502s  976773119s  832239618s  extended
 5      144533504s  451244031s  306710528s  logical   ext4
 6      451246080s  518592511s  67346432s   logical   ext4
 8      518594560s  606562303s  87967744s   logical   ext4
 7      606564352s  976773119s  370208768s  logical   ext4

Retour à Clonezilla

clonezilla

Puis device-image / skip
Entrée
Beginner
recovery-iso-zip

Conf par défaut

umount /home/partimag/
halt
Notes

Le fichier sda-pt.parted semble avoir été généré à l'aide de la commande

parted /dev/sdb unit s print > sda-pt.parted
2025/03/24 15:06

Pb de format clefs SSH générées sous windows avec Putty

Voici le format en question

---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key-20180404"
AAAAB3NzaD2yc2EAAAABJQAAAQEAkv55JvWzeWFQcDjQQ5JbkWj4t+9qFft5ZfHX
ihJHElLi/xsC61SMG8fTze+RsPhv4UGzer3xTun4/5qOXbLtY4Gtn+rjspuu5q4j
Kzb2uUomaF5O0obvqcD2JqLaypHLsYefqyztjJG++YhU6wA4F+3CHb+XzCF+uFp7
UmWcS4v6VO65rBiWKfwL8t+FBEvOxa0zAm1p5//p+WIQSzk7JJFFQ2DewIGm9aus
qcSyqDqbZR7Pqy1G/JRSw6CkVNKNO1P+JNdVRD6u9X1bf03dMTLbJNSkrc3wtZdV
H72idCUC3kE2FwK6f9tT8LcWbJWNEpgfeMoblIjacij7BThYCP==
---- END SSH2 PUBLIC KEY ----

Conversion

ssh-keygen -i -f /home/bob/clef_format_putty >> /home/bob/.ssh/authorized_keys
chown bob: /home/bob/.ssh/authorized_keys
2025/03/24 15:06

Pb curl TLS NOK - RedHat 6 et 7 LIBNSS - NSS error -8102

  • L'erreur n'apparait qu'avec la LIBCURL, ça fonctionne bien avec OpenSSL et wget.
  • L'erreur n'apparait que sur RedHat 6 et 7, pas sur RedHat 5, 8, 9

En effet la LIBCURL de RedHat 6 et 7 est compilé avec LIBNSS

# ldd /usr/bin/curl |grep nss
        libnss3.so => /usr/lib64/libnss3.so (0x00007fa6093c6000)
        libnssutil3.so => /usr/lib64/libnssutil3.so (0x00007fa609196000)

Voici l'erreur

$ curl --show-error -v https://nok.acme.fr
* About to connect() to proxy localhost port 8080 (#0)
*   Trying ::1... connected
* Connected to localhost (::1) port 8080 (#0)
* Establish HTTP proxy tunnel to nok.acme.fr:443
> CONNECT nok.acme.fr:443 HTTP/1.1
> Host: nok.acme.fr:443
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.44 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 200 Connection established
<
* Proxy replied OK to CONNECT request
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* Bad certificate received. Subject = 'CN=nok.acme.fr,OU=ACME,OU=Private Group PKI,O=ACME Group,C=FR', Issuer = 'CN=PKI SERVER,OU=Private Group PKI,O=ACME Group,C=FR'
* NSS error -8102
* Closing connection #0
* Peer certificate cannot be authenticated with known CA certificates
curl: (60) Peer certificate cannot be authenticated with known CA certificates
More details here: http://curl.haxx.se/docs/sslcerts.html
Constant Value Description
SEC_ERROR_INADEQUATE_KEY_USAGE -8102 Certificate key usage inadequate for attempted operation.

Source : NSS and SSL Error Codes

Premièrement il convient de s'assurer que le problème n'est pas dû au proxy HTTP

proxytunnel -p proxy:8080 -d nok.acme.fr:443 -a 7000 &
curl --noproxy '*' -D - -v -s -H "Host: nok.acme.fr" https://localhost:7000

Le pb est toujours présent

Test OK avec OpenSSL

openssl s_client -connect localhost:7000 -servername nok.acme.fr </dev/null > /dev/null 2>&1 && echo OK
$ openssl s_client -connect ok.acme.fr:443 -servername ok.acme.fr </dev/null 2>/dev/null | openssl x509 -noout -text | grep -A1 "X509v3 Key Usage: critical"
            X509v3 Key Usage: critical
                Digital Signature, Key Encipherment

$ openssl s_client -connect localhost:7000 -servername nok.acme.fr </dev/null 2>/dev/null | openssl x509 -noout -text | grep -A1 "X509v3 Key Usage: critical"
            X509v3 Key Usage: critical
                Digital Signature, Non Repudiation

Le pb est que le certificat du serveur ne contient pas le “Usage” : Key Encipherment

Autres

Ciphers

Pour des problèmes similaires il peut être intéressant de vérifier si ce n'est pas un lié au Ciphers

$ openssl s_client -connect localhost:7000 -servername nok.acme.fr </dev/null 2>/dev/null | grep Cipher
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES128-GCM-SHA256
    Cipher    : ECDHE-RSA-AES128-GCM-SHA256
$ /usr/lib64/nss/unsupported-tools/listsuites
...
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:
  0xc02f ECDHE RSA   AES-GCM  128 AEAD   Enabled  FIPS Domestic
...
keyUsage

Voir aussi :

$ openssl x509 -noout -ext keyUsage < entity.pem
X509v3 Key Usage: critical
    Digital Signature, Key Encipherment

$ openssl x509 -noout -ext keyUsage < intermediate.pem
X509v3 Key Usage: critical
    Certificate Sign, CRL Sign

Source : https://docs.apigee.com/how-to-guides/validating-certificate-purpose?hl=fr

2025/03/24 15:06

Pb curl 77 error setting certificate verify locations

Source : https://www.plesk.com/kb/support/on-plesk-for-linux-server-curl-command-in-chrooted-shell-or-in-scheduled-task-fails-

Both for chrooted shell and scheduled tasks

Create directories for CA certificates in the chroot template:

mkdir -p /var/www/vhosts/chroot/etc/ssl/certs/
mkdir -p /var/www/vhosts/chroot/usr/share/ca-certificates/

Copy the CA certificates to those directories:

cp -a /etc/ssl/certs/* /var/www/vhosts/chroot/etc/ssl/certs/
cp -a /usr/share/ca-certificates/* /var/www/vhosts/chroot/usr/share/ca-certificates/

Update the chroot template by running below commands one by one:

curl -o update-chroot.sh https://raw.githubusercontent.com/plesk/kb-scripts/master/update-chroot/update-chroot.sh
chmod 700 update-chroot.sh
./update-chroot.sh --apply all

Autres

/etc/pki/tls/certs/ca-bundle.crt

2025/03/24 15:06
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki