Pass to menadżer haseł, który realizuje filozofię prostoty, uniwersalności – czyli tego, czego de facto oczekujemy od Unixa. Nie ważne, czyli jesteśmy akurat na serwerze, czy na desktopie, czy w kontenerze – pass może być wykorzystany absolutnie wszędzie. To, co równie ważne, to jego uniwersalność – jest dostępny z linii poleceń. Pass to wrapper na szyfrowane pliki ogarniane przez gpg.

Instalacja pass

To process trywialny. Instalacja sprowadza się do jednej linijki kodu:

				
					apt install pass
				
			

À propos instalacji: domyślnie na swoim blogu będę używał kodu, który można użyć w Debianie/Ubuntu. Najbardziej je lubię, Dlaczego? Nie wiem ¯\_(ツ)_/¯ I od razu kwestia używanego języka. Uważam, że język angielski jest językiem technologii, dlatego linki, kod, pseudokod, itd., będą w języku angielskim, chyba, że akurat wklei mi się link do Wikipedii w języku polskim.

Konfiguracja pass

Tu wkraczamy do meritum. Jak skonfigurujemy pass, to będziemy mogli z niego korzystać jak z pełnoprawnego menadżera haseł. Warto zatem poświęcić chwilę na przygotowanie sobie narzędzia w taki sposób, by nam służyło jak najdłużej, a jego konfiguracja była procesem jednorazowym.

Krok 1: klucz GPG

Wszędzie tam, gdzie mamy doczynienia z szyfrowaniem, tam mamy doczynienia z jakimś kluczem. W przypadku pass mamy doczynienia z kluczem gpg, który musimy wygenerować.

Klucz gpg generujemy w następujący sposób:

				
					gpg2 --gen-key
				
			

Spodziewany output:

				
					gpg2 --gen-key
gpg (GnuPG) 2.4.4; Copyright (C) 2024 g10 Code GmbH
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

gpg: directory '/home/milosz/.gnupg' created
gpg: keybox '/home/milosz/.gnupg/pubring.kbx' created
Note: Use "gpg --full-generate-key" for a full featured key generation dialog.

GnuPG needs to construct a user ID to identify your key.

Real name: Milosz Rycko-Bozenski
Email address: x@domain.example
You selected this USER-ID:
    "Milosz Rycko-Bozenski <x@domain.example>"

Change (N)ame, (E)mail, or (O)kay/(Q)uit? O

We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.

We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.

gpg: /home/milosz/.gnupg/trustdb.gpg: trustdb created
gpg: directory '/home/milosz/.gnupg/openpgp-revocs.d' created
gpg: revocation certificate stored as '/home/milosz/.gnupg/openpgp-revocs.d/XYZ.rev'
public and secret key created and signed.

pub   ed25519 YYYY-mm-dd [SC] [expires: YYYY-mm-dd]
XYZ
uid Milosz Rycko-Bozenski <x@domain.example>
sub   cv25519 YYYY-mm-dd [E] [expires: YYYY-mm-dd]
				
			

lub:

				
					gpg2 --full-gen-key
				
			

W tym przypadku możemy mieć kontrolę nad opcjami:

  • rodzaj klucza,
  • krzywa eliptyczna,
  • data ważności.
				
					Please select what kind of key you want:
   (1) RSA and RSA
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
   (9) ECC (sign and encrypt) *default*
  (10) ECC (sign only)
  (14) Existing key from card
  
Your selection? 9

Please select which elliptic curve you want:
   (1) Curve 25519 *default*
   (4) NIST P-384
   (6) Brainpool P-256

Your selection? 1

Please specify how long the key should be valid.
         0 = key does not expire
      <n>  = key expires in n days
      <n>w = key expires in n weeks
      <n>m = key expires in n months
      <n>y = key expires in n years
      
Key is valid for? (0) 0

Key does not expire at all

Is this correct? (y/N) y
				
			

Krok 2: Inicjacja

Skoro mamy już klucz gpg, to czas zrobić z niego użytek, która – tut tu ru ru – jest trywialna.

				
					gpg2 --list-secret-keys
pass init GPG-KEY-ID
				
			

Dodaj komentarz

Twój adres e-mail nie zostanie opublikowany. Wymagane pola są oznaczone *