Outils pour utilisateurs

Outils du site


blog

Notes GPG - Two cards with same subkeys

GPG - carte a puce - utiliser plusieurs cartes avec les mêmes clefs secrètes

Voir :

Backup GPG cards

Voir :

Pb - Error Please insert card with serial number 0001 12345678

$ diff .gnupg.nitrokey/private-keys-v1.d/AF710C976166A34B065DAF48430F30FEE69DA9D9.key .gnupg.yubykey/private-keys-v1.d/AF710C976166A34B065DAF48430F30FEE69DA9D9.key
6c6
<   (#D27600012401030400050000A44B0000# OPENPGP.1))))
---
>   (#D2760001240103040006142373880000# OPENPGP.1))))

$ diff .gnupg.nitrokey/private-keys-v1.d/C98A50CAD33BE20FCC23425F9FAA782B5195A9D2.key .gnupg.yubykey/private-keys-v1.d/C98A50CAD33BE20FCC23425F9FAA782B5195A9D2.key 
6c6
<   (#D27600012401030400050000A44B0000# OPENPGP.2))))
---
>   (#D2760001240103040006142373880000# OPENPGP.2))))
$ gpg --card-status  |grep 'card-no'
                                          card-no: 0006 14237388
                                          card-no: 0006 14237388
$ gpg --card-status |grep "^Application ID"
Application ID ...: D27600012401030400050000A44B0000
$ opensc-tool -l 
# Detected readers (pcsc)
Nr.  Card  Features  Name
0    Yes             Nitrokey Nitrokey Pro (00000000000000000000A44B) 00 00
D276000124010304 00050000A44B0000
D276000124010304 + '0006 14237388' + '0000'
D2760001240103040006142373880000

Voici comment trouver ce numéro

$ opensc-explorer 
OpenSC Explorer version 0.21.0
Using reader with a card: Nitrokey Nitrokey Pro (00000000000000000000A44B) 00 00
OpenSC [3F00]> ls
FileID  Type  Size
 004F    wEF    16
 005E    wEF    19
[0065]    DF    32
[006E]    DF   244
[007A]    DF     5
 00C4    wEF     7
 0101    wEF     0
 0102    wEF     0
 0103    wEF     0
 0104    wEF     0
 5F50    wEF     0
 5F52    wEF    10
 7F21    wEF     0
[A400]    DF     0
 A401    wEF     0
[B600]    DF   136
 B601    wEF   158
[B800]    DF   136
 B801    wEF   158
OpenSC [3F00]> cat 004F
00000000: D2 76 00 01 24 01 03 04 00 05 00 00 A4 4B 00 00 .v..$........K..

Seulement voilà cette manip ne fonctionne pas la Yubikey

$ openpgp-tool -C
Using reader with a card: Yubico YubiKey OTP+FIDO+CCID 00 00
AID:             d2:76:00:01:24:01:03:04:00:06:14:23:73:88:00:00
Version:         3.4
Manufacturer:    Yubico
Serial number:   14237388

Voir aussi

$ opensc-tool --atr 
Using reader with a card: Yubico YubiKey OTP+FIDO+CCID 00 00
3b:fd:13:00:00:81:31:fe:15:80:73:c0:21:c0:57:59:75:62:69:4b:65:79:40
$ opensc-tool -a -v
Using reader with a card: Yubico YubiKey OTP+FIDO+CCID 00 00
Card ATR:
3B FD 13 00 00 81 31 FE 15 80 73 C0 21 C0 57 59 ;.....1...s.!.WY
75 62 69 4B 65 79 40                            ubiKey@

Exemple

La commande ci dessous ne fonctionne pas, ce n'est pas la bonne clef

$ gpg ~/tmp/plop.txt.gpg 
Please insert the card with serial number: 0005 0000BD62

Mais où est donc (ornicar ?) l'id 0000BD62 ?

$ rgrep 0000BD62 ~/.gnupg
~/.gnupg/private-keys-v1.d/F66AA9329AEA6F09D69DD852BF8233DE68119AF5.key:Token: D27600012401030400050000BD620000 OPENPGP.3 - 0005+0000BD62
~/.gnupg/private-keys-v1.d/F66AA9329AEA6F09D69DD852BF8233DE68119AF5.key:  (#D27600012401030400050000BD620000# OPENPGP.3))))
~/.gnupg/private-keys-v1.d/3F5417680639FCEF05C54803B408B83BA496E964.key:Token: D27600012401030400050000BD620000 OPENPGP.1 - 0005+0000BD62
~/.gnupg/private-keys-v1.d/3F5417680639FCEF05C54803B408B83BA496E964.key:  (#D27600012401030400050000BD620000# OPENPGP.1))))
~/.gnupg/private-keys-v1.d/DC81057888D07B12268226B9F136013C4D32566D.key:Token: D27600012401030400050000BD620000 OPENPGP.2 - 0005+0000BD62
~/.gnupg/private-keys-v1.d/DC81057888D07B12268226B9F136013C4D32566D.key:  (#D27600012401030400050000BD620000# OPENPGP.2))))

Trouver l'id la clef actuelle

$ gpg --card-status |grep "^Application ID"
Application ID ...: D2760001240103040006142373880000

On remplace l'ancien id par le nouveau

cp -a ~/.gnupg ~/.gnupg.bak
sed -i -e 's/D27600012401030400050000BD620000/D2760001240103040006142373880000/g' ~/.gnupg/private-keys-v1.d/*.key

Ça fonctionne

gpg ~/tmp/plop.txt.gpg

Autre

Python et carte GPG

Export / Import FIXME

python3 -m gpgcard.gpgcli --backup --pinpad --backup-keys --file gpg-key.pickle
 
python3 -m gpgcard.gpgcli --restore --pinpad --file gpg-key.pickle
2025/03/24 15:06

Gostcrypt

Voir :

Voir aussi :

  • VeraCrypt (anciennement TrueCrypt)
  • Cryptsetup - luks
  • wipefs

Installation

wget "https://www.gostcrypt.org/download/1.0/linux/Gostcrypt_1.0.deb"
sha256sum Gostcrypt_1.0.deb
dpkg -i Gostcrypt_1.0.deb
apt-get -f install

config du sudoers Normalement pas nécessaire, sauf pour disque ou partition entière Attention a ne pas autoriser n'importe qui !
Car droit de détruire le système de fichier

visudo -f /etc/sudoers.d/gostcrypt
/etc/sudoers.d/gostcrypt
jean       ALL=(root) NOPASSWD: /usr/bin/gostcrypt

Test

gostcrypt --test

Pour une utilisation en ligne de commande sans sortie sur le serveur X

unset DISPLAY

Création d'un clef

gostcrypt --create-keyfile key < /dev/urandom

Pour l'aide

gostcrypt -t --help |less

Création d'un volume en ligne de commande (mode fichier)

gostcrypt -t -k key -c disk --encryption="GOST 28147-89" --hash="GOST R 34.11-2012" -password="" --volume-type=normal --random-source=/dev/urandom --filesystem=none --size=$((100 * 1024 * 1024))

Création d'un volume en ligne de commande (mode disque / partition)

gostcrypt -t -k /home/jean/key -c /dev/sdg --encryption="GOST 28147-89" --hash="GOST R 34.11-2012" -password="" --volume-type=normal --random-source=/dev/urandom --filesystem=none
sudo gostcrypt -t --filesystem=none --protect-hidden=no -password="" -k /home/jean/key /dev/sdb
$ gostcrypt -t -l
1: /home/jean/disk /dev/loop0 -

Vérifions que la taille correspond bien à notre nouveau volume chiffré

fdisk -l /dev/loop0

Formatons !

mkfs.ext4 /dev/loop0

On monte la partition

mount -o noatime /dev/loop0 /mnt/gostcrypt/
df -hP /mnt/gostcrypt/

Quand on a fini

umount /mnt/gostcrypt 
gostcrypt -t -d

Bug

Error: No such file or directory

Solution : Prendre l'ancienne version gostcrypt_debian_7.4_amd64

Liens :

Accroire la sécurité en utilisant plusieurs clefs

La taille fixe de clef, limité à 64 octets n'est pas une limite.

Ici nous allons utiliser un gros fichier (monfichierclef) que nous allons chiffrer avec une petite sous-clef (k1.txt). Tout cela pour créer une nouvelle clef (k2)

cat monfichierclef |openssl enc -bf -S abcd -out k2 -pass file:k1.txt

L'option -S, c'est le sel (salt), ici abcd. Il doit être en hexadécimal.
Sans cela la commande openssl, créerai à chaque fois un fichier k2 différant

Les clefs doivent obligatoirement faire une taille de 64 octets, découpons k2 en plusieurs petites clefs

mkdir plop
cd plop
split -b 64 ../k2

Nous effaçons le seul fichier qui ne fait pas exactement 64 octets, c'est à dire le dernier généré (tronqué)

find ../plop -not -size 64c -delete

Voilà comment utiliser toutes les clefs pour créer un volume

gostcrypt -t -k $(echo *|tr " " ",") -c ../disk --encryption="GOST 28147-89" --hash="GOST R 34.11-2012" -password="" --volume-type=normal --random-source=/dev/urandom --filesystem=none --size=$((100 * 1024 * 1024)

Pb install

wget https://www.gostcrypt.org/download/1.0/linux/Gostcrypt_1.0.deb
dpkg -i Gostcrypt_1.0.deb
# apt-get -f install
Unpacking libgl1-mesa-dri:amd64 (from .../libgl1-mesa-dri_8.0.5-4+deb7u2_amd64.deb) ...
dpkg: error processing /var/cache/apt/archives/libgl1-mesa-dri_8.0.5-4+deb7u2_amd64.deb (--unpack):
 trying to overwrite shared '/etc/drirc', which is different from other instances of package libgl1-mesa-dri:amd64
Processing triggers for man-db ...
Errors were encountered while processing:
 /var/cache/apt/archives/libgl1-mesa-dri_8.0.5-4+deb7u2_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Si erreur, relancer la commande :

apt-get -f install
2025/03/24 15:06

Notes GostCrypt package deb

Voir :

GostCrypt_1.3 sur Debian Wheezy

Ouverture du paquage Debian

wget http://www.gostcrypt.org/download/1.3/Linux/Deb/GostCrypt_1.3_Debian.x86_64.deb
mkdir ~/GostCrypt_1.3_Debian_Wheezy
cd ~/GostCrypt_1.3_Debian_Wheezy/
ar x ../GostCrypt_1.3_Debian.x86_64.deb
tar --same-owner xvf data.tar.xz
mkdir DEBIAN
cd DEBIAN
tar xvf ../control.tar.gz
rm control.tar.gz  data.tar.xz  debian-binary

Compilation

https://www.gostcrypt.org/wiki/doku.php?id=compilation_installation:compilation:linux:ubuntu

Install des dépendances

sudo apt-get install libfuse-dev libwxgtk2.8-dev pkg-config
wget http://www.gostcrypt.org/download/1.3/Linux/Sources/GostCrypt_1.3_Linux.tar.gz
tar xvf GostCrypt_1.3_Linux.tar.gz
 
make NOGUI=1

L'éxecutable est ici :
./Main/gostcrypt.cli

Modification du paquage

rm -f ~/GostCrypt_1.3_Debian_Wheezy/usr/bin/gostcrypt.cli ~/GostCrypt_1.3_Debian_Wheezy/usr/bin/gostcrypt
cp -p Main/gostcrypt.cli ~/GostCrypt_1.3_Debian_Wheezy/usr/bin
cd  ~/GostCrypt_1.3_Debian_Wheezy
rm -rf usr/share/applications/ usr/share/Gostcrypt/
$ cat DEBIAN/control
- Depends: libc6, libfuse2, libgcc1, libstdc++6, libwxbase3.0-dev , libwxgtk3.0-dev
+ Depends: libc6, libfuse2, libgcc1, libstdc++6, libwxbase2.8-dev
- Version: 1.3
+ Version: 1.3~Jb
cd /usr/bin
ln -s gostcrypt.cli gostcrypt

Reconstruction du paquet

cd ~/GostCrypt_1.3_Debian_Wheezy
md5sum $(find . -not -wholename "./DEBIAN/*" -type f -not -name "debian-binary" )> DEBIAN/md5sums
cd ~
dpkg-deb --build GostCrypt_1.3_Debian_Wheezy

Installation

dpkg -i GostCrypt_1.3_Debian_Wheezy.deb

FIXME

2025/03/24 15:06

Notes GOGS forge git serveur github like

Voir aussi :

Voir :

wget https://dl.gogs.io/gogs_v0.9.141_linux_amd64.zip
unzip gogs_v0.9.141_linux_amd64.zip
 
cd gogs

Gogs ne fonctionne pas directement avec git-shell

fatal: Could not read from remote repository.
Please make sure you have the correct access rights
# Delete
passwd -d git
 
# Lock
passwd -l git
 
usermod -s /bin/bash git

/etc/ssh/sshd_config

AllowUsers plop git

Match User git
    PasswordAuthentication no
service ssh restart
apt-get install supervisor

/etc/supervisor/conf.d/gogs.conf

[program:gogs]
directory=/home/git/gogs/
command=/home/git/gogs/gogs web
autostart=true
autorestart=true
startsecs=10
stdout_logfile=/var/log/gogs/stdout.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stdout_capture_maxbytes=1MB
stderr_logfile=/var/log/gogs/stderr.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
stderr_capture_maxbytes=1MB
user = git
environment = HOME="/home/git", USER=git"

Pour faire fonctionner SMTP et avoir les notifications par mails :

/home/git/gogs/custom/conf/app.ini

[mailer]
SKIP_VERIFY = true

Sur poste client

Il est possible d'utiliser HTTP(S) ou SSH

Exemple de conf SSH pour utiliser un proxy d'entreprise

~/.ssh/config

Host git.acme.fr
    User git
    Hostname git.acme.fr
    Port 443
    ProxyCommand /usr/bin/corkscrew 192.168.56.1 3128 %h %p

Conf complète app.ini

/home/git/gogs/custom/conf/app.ini

APP_NAME = Gogs: Go Git Service
RUN_USER = git
RUN_MODE = prod
 
[database]
DB_TYPE  = sqlite3
HOST     = 127.0.0.1:3306
NAME     = gogs
USER     = root
PASSWD   = 
SSL_MODE = disable
PATH     = data/gogs.db
 
[repository]
ROOT = /home/git/gogs-repositories
 
[server]
DOMAIN       = git.acme.fr
HTTP_PORT    = 3000
ROOT_URL     = https://git.acme.fr/
DISABLE_SSH  = false
SSH_PORT     = 443
OFFLINE_MODE = true
 
[mailer]
ENABLED = true
HOST    = localhost:25
FROM    = GOGS <git@acme.fr>
USER    = 
PASSWD  = 
SKIP_VERIFY = true
 
[service]
REGISTER_EMAIL_CONFIRM = false
ENABLE_NOTIFY_MAIL     = true
DISABLE_REGISTRATION   = true
ENABLE_CAPTCHA         = false
REQUIRE_SIGNIN_VIEW    = true
 
[picture]
DISABLE_GRAVATAR        = true
ENABLE_FEDERATED_AVATAR = false
 
[session]
PROVIDER = file
 
[log]
MODE      = file
LEVEL     = Info
ROOT_PATH = /home/git/gogs/log
 
[security]
INSTALL_LOCK = true
SECRET_KEY   = JziSLMT87mxkURM
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