Add `PASSWORD_STORE_CHARACTER_SET` in pass description

This commit is contained in:
Fabrice Mouhartem 2024-02-24 19:01:21 +01:00
parent eb653d1196
commit 39a90c8245
2 changed files with 46 additions and 3 deletions

View File

@ -1,7 +1,7 @@
---
Title: Gérer vos mots de passe avec pass
Date: 2019-04-22 19:00
Modified: 2019-04-24 11:12
Modified: 2024-02-24 18:00
Lang: fr
Author: Fabrice
Category: programmes
@ -32,6 +32,28 @@ Pour **re**générer un mot de passe, loption `-i` ici est **importante** pui
Cela évite donc de devoir utiliser du [git sale]({filename}/cheat-sheets/git-fr.md) pour retirer lerreur de larbre des commits vu que `pass <cmd>` fait automatiquement un commit atomique à la fin de la commande.
Je loublie parfois, cest pourquoi je laisse ça ici en guise de rappel.
Sur certains services, il arrive que lon ait besoin de spécifier un ensemble de caractères admissibles pour les mots de passe.
Cela peut être fait via la variable denvironnement `PASSWORD_STORE_CHARACTER_SET`.
Le contenu de cette variable est transmis à la [commande `tr`](https://fr.wikipedia.org/wiki/Tr_(Unix)).
Ainsi, pour créer un code PIN, on peut spécifier la valeur suivante: `PASSWORD_STORE_CHARACTER_SET='[:digit:]'` et indiquer la longueur désirée du mot de passe en dernier argument de la commande.
Par exemple, pour générer un code PIN de 6 chiffres:
```sh
PASSWORD_STORE_CHARACTER_SET='[:digit:]' pass generate <pass-name> 6
```
Je nai en revanche pas trouvé comment forcer la présence de caractères spéciaux… je lance donc la commande plusieurs fois dans ces cas avec loption `-i` pour écrire en place après la première tentative.
Ce nest pas la meilleure solution, qui en plus pollue lhistorique git mais bon… ça fonctionne.
Par exemple, pour générer un mot de passe sur un service _fictif_ qui supporterait les caractères spéciaux suivants: `-_@$<>` pour des mots de passe dau plus 20 caractères, on peut utiliser la commande suivante:
```sh
PASSWORD_STORE_CHARACTER_SET='[:alnum:]-_@$<>' pass generate <pass-name> 20
```
Pour finir:
```sh
pass git <ce que vous voulez>
```

View File

@ -1,7 +1,7 @@
---
Title: Manage your passwords with pass
Date: 2019-04-22 19:00
Modified: 2019-04-23 14:24
Modified: 2024-02-24 18:00
Author: Fabrice
Category: software
Tags: pass, git, cli
@ -28,7 +28,28 @@ Here are just some commands I often use.
```sh
pass generate -i <pass-name>
```
To regenerate a password, the `-i` is important to avoid overwritting the whole file and having to rely on [dirty git]({filename}/cheat-sheets/git.md) to withdraw your mistake (`pass <cmd>` will automatically commit your change)… I sometimes forget it, so let's put it here as a reminder.
To regenerate a password, the `-i` is important to avoid overwriting the whole file and having to rely on [dirty git]({filename}/cheat-sheets/git.md) to withdraw your mistake (`pass <cmd>` will automatically commit your change)… I sometimes forget it, so let's put it here as a reminder.
Sometimes it can be useful to specify the accepted special chars, this can be done using the `PASSWORD_STORE_CHARACTER_SET` environment variable.
This value is interpreted by the [`tr` command](https://en.wikipedia.org/wiki/Tr_(Unix)),
hence to create a PIN, you can use the following value: `PASSWORD_STORE_CHARACTER_SET='[:digit:]'`, then specify the length with the last argument.
For instance, to generate a 6 digit PIN:
```sh
PASSWORD_STORE_CHARACTER_SET='[:digit:]' pass generate <pass-name> 6
```
I didnt manage to specify how to have at least one of them, so I run the command multiple times (with the `-i` option to change the file in place after the first one)…
It pollutes a bit the git history but, well… it works.
For instance, for a service supporting only the following characters: `-_@$<>` of at most 20 char long (fictive example), you can use the following command:
```sh
PASSWORD_STORE_CHARACTER_SET='[:alnum:]-_@$<>' pass generate <pass-name> 20
```
To finish:
```sh
pass git <whatever you want>