22
0
Fork 0
wiki/HowtoKeePassX.md

258 lines
8.7 KiB
Markdown
Raw Permalink Normal View History

2017-10-03 12:04:00 +02:00
---
2017-10-04 23:46:27 +02:00
categories: desktop sécurité
2017-10-03 12:04:00 +02:00
title: Howto KeepassX
...
2016-09-26 13:50:18 +02:00
2017-10-21 17:30:18 +02:00
* Code source : <https://github.com/keepassx/keepassx>
2017-10-04 23:46:27 +02:00
[KeePassX](https://www.keepassx.org/) est un logiciel de gestion des mots de passe pour Linux/Windows/Mac. Il permet de générer, stocker et organiser ses mots de passe tout en les protégeant avec un chiffrement AES (clé de 256 bits).
KeePassX est un fork du logiciel [KeePass](http://keepass.info/) avec lequel son format de stockage (.kdb/.kdbx) est compatible. Il existe aussi [KeePassXC](https://keepassxc.org/) un fork de… KeePassX que nous n'utilisons pas pour l'instant.
2017-10-03 12:24:56 +02:00
2017-10-04 11:48:48 +02:00
* KeePassX 0.4 utilise le format **.kdb** (compatible avec KeePass 1)
* KeePassX 2 utilise le format **.kdbx** (compatible avec KeePass 2) et peut lire le format **.kdb** (lecture seule et conversion au format .kdbx)
2016-09-26 13:50:18 +02:00
2022-12-01 17:25:13 +01:00
**Chez Evolix nous utilisons désormais KeePassXC et le format .kdbx**
2016-09-26 13:50:18 +02:00
## Installation
~~~
2017-10-04 11:48:48 +02:00
# apt install keepassx kpcli libcapture-tiny-perl libclipboard-perl
$ keepassx -v
keepassx 2.0.3
2016-09-26 13:50:18 +02:00
~~~
2017-10-04 11:48:48 +02:00
> *Note* : Pour Debian 8, on peut faire :
>
> ~~~
> # echo "deb http://mirror.evolix.org/debian jessie-backports main" > /etc/apt/sources.list.d/backports.list
> # apt install keepassx/jessie-backports kpcli libcapture-tiny-perl
2017-10-04 11:48:48 +02:00
> ~~~
2022-02-28 15:10:27 +01:00
Les paquets `libcapture-tiny-perl` et `libclipboard-perl` (disponibles uniquement sous *Stretch*) permettent d'avoir accès aux commandes xu/xp/xw/xx de _kpcli_ pour placer le login ou mot de passe directement dans le presse-papier.
2017-10-03 12:24:56 +02:00
2016-09-26 13:50:18 +02:00
2017-10-04 12:08:28 +02:00
## Utilisation
2017-10-03 12:04:00 +02:00
2017-10-04 11:48:48 +02:00
Vous pouvez créer un fichier .kdbx protégé par mot de passer et/ou clé pour stocker vos mots de passe :
~~~
2017-10-04 12:08:28 +02:00
Base de données> Nouvelle base de données> Mot de passe: PASSWORD > OK > Enregistrer la base de données
2017-10-04 11:48:48 +02:00
~~~
2016-09-26 13:50:18 +02:00
2017-10-04 11:48:48 +02:00
Vous pourrez ultérieurement l'utiliser via la commande :
2016-09-26 13:50:18 +02:00
~~~
2017-10-04 23:46:27 +02:00
$ keepassx db.kdbx
~~~
### Raccourcis
* `Ctrl+u` : ouvrir l'URL dans votre navigateur
* `Ctrl+v` : tente de remplir directement les champs dans votre navigateur (à utiliser avec précaution)
* `Ctrl+B` : copier le login dans le presse-papier
2018-01-23 16:00:46 +01:00
* `Ctrl+C` : copier le mot de passe dans le presse-papier
2017-10-04 23:46:27 +02:00
* `Ctrl+Alt+u` : copier l'URL dans le presse-papier
### Verrouillage
2017-10-05 16:37:53 +02:00
Nous conseillons de configurer un verrouillage automatique de votre KeePassX via :
2017-10-04 23:46:27 +02:00
~~~
Outils> Paramètres> Sécurité
2016-09-26 13:50:18 +02:00
~~~
2017-10-04 21:33:51 +02:00
### Convertir un fichier .kdb en .kdbx
2017-10-04 12:08:28 +02:00
~~~
Base de données> Importer une base de données KeePass
~~~
2017-10-04 11:48:48 +02:00
2017-10-04 21:33:51 +02:00
il faut ensuite sauvegarder la nouvelle base de données importée du fichier .kdb
2023-03-08 15:06:52 +01:00
## keepassxc-cli
C'est la version CLI de KeepassXC, elle na pas été vraiment concu pour un usage quotidien mais plutot pour l'utiliser dans des scripts (bien que sa sortie ne soit [pas simplement parseable](https://github.com/keepassxreboot/keepassxc/issues/6011)).
### Créer une nouvelle base
~~~
$ keepassxc-cli db-create --set-password /tmp/foo.kdbx
Enter password to encrypt database (optional):
Repeat password:
Successfully created new database.
~~~
### Ajouter une entrée
~~~
$ keepassxc-cli add --username alice --password-prompt /tmp/foo.kdbx bar
Enter password to unlock /tmp/foo.kdbx:
Enter password for new entry:
Successfully added entry bar.
~~~
### Aficher une entrée
~~~
$ keepassxc-cli show --show-protected /tmp/foo.kdbx bar
Enter password to unlock /tmp/foo.kdbx:
Title: bar
UserName: alice
Password: bob
URL:
Notes:
Uuid: {0310de64-3f68-4a94-840d-6b35e6c1d8cf}
Tags:
~~~
### TOTP
#### Ajouter un secret TOTP
Il n'est pas possible d'ajouter un secret TOTP en ligne de commande, car aucune des commandes `add` ou `edit` ne permet de spécifier un attribut. Dans KeepasXC les secrets TOTP sont stockés dans l'attribut `totp` sous la frome d'URL comme celle ci `otpauth://totp/totp@authenticationtest.com?secret=I65VU7K5ZQL7WB4`.
Il est prévu que la version 2.8 de KeepassXC supporte cette fonctionalité via la [PR #7462](https://github.com/keepassxreboot/keepassxc/issues/7462), cette demande de fonctionalité est suivi dans l'[issue #9212](https://github.com/keepassxreboot/keepassxc/issues/9212).
#### Génerer un jeton TOTP
~~~
$ keepassxc-cli show --totp /tmp/foo.kdbx bar
Enter password to unlock /tmp/foo.kdbx bar:
123456
~~~
2016-09-26 13:50:18 +02:00
## kpcli
2017-10-04 23:46:27 +02:00
[kpcli](http://kpcli.sourceforge.net/) est un utilitaire permettant la manipulation de fichier .kdbx (ou .kbd) depuis la console. Il couvre les fonctions principales de KeePassX (copie du login/mot de passe dans le presse-papier, arborescence conservée, création de nouvelles entrées etc.)
> *Note* : la gestion du format Keepass n'est pas strictement identique entre kpcli et KeePassX, par exemple kpcli gère les tags mais pas KeePassX. Si vous en ajoutez avec kpcli, ils ne seront donc pas visibles avec KeePassX !
2017-10-03 12:04:00 +02:00
### Créer une nouvelle base
2017-10-04 21:33:51 +02:00
Il suffit de lancer `kpcli` sans argument, puis de sauvegarder :
2017-10-03 12:04:00 +02:00
~~~
$ kpcli
2017-10-04 21:33:51 +02:00
KeePass CLI (kpcli) v3.1 is ready for operation.
2017-10-04 12:30:14 +02:00
kpcli:/> saveas foo.kdbx
2017-10-03 12:04:00 +02:00
Please provide the master password: *************************
Retype to verify: *************************
~~~
### Utilisation courante
2017-10-03 12:24:56 +02:00
kpcli a quelques options au démarrage. Les plus utiles étant :
2017-10-04 21:33:51 +02:00
* `--kdb FICHIER` - Spécifie le fichier .kdbx à ouvrir.
2017-10-04 23:49:27 +02:00
* `--readonly` - Ouverture de la base de données en lecture seule
2016-09-26 13:50:18 +02:00
~~~
2017-10-04 23:49:27 +02:00
$ kpcli --readonly --kdb foo.kdbx
2016-09-26 13:50:18 +02:00
Please provide the master password: *************************
2017-10-04 21:33:51 +02:00
2016-09-26 13:50:18 +02:00
Type 'help' for a description of available commands.
Type 'help <command>' for details on individual commands.
2017-10-03 12:33:02 +02:00
kpcli:/> help
attach -- Manage attachments: attach <path to entry|entry number>
cd -- Change directory (path to a group)
cl -- Change directory and list entries (cd+ls)
clone -- Clone an entry: clone <path to entry> <path to new entry>
close -- Close the currently opened database
cls -- Clear screen ("clear" command also works)
copy -- Copy an entry: copy <path to entry> <path to new entry>
edit -- Edit an entry: edit <path to entry|entry number>
2017-10-04 12:30:14 +02:00
export -- Export entries to a new KeePass DB (export <file.kdbx> [<file.key>])
2017-10-03 12:33:02 +02:00
find -- Finds entries by Title
help -- Print helpful information
history -- Prints the command history
icons -- Change group or entry icons in the database
2017-10-04 12:30:14 +02:00
import -- Import another KeePass DB (import <file.kdbx> <path> [<file.key>])
2017-10-03 12:33:02 +02:00
ls -- Lists items in the pwd or a specified path ("dir" also works)
mkdir -- Create a new group (mkdir <group_name>)
mv -- Move an item: mv <path to group|entry> <path to group>
new -- Create a new entry: new <optional path&|title>
2017-10-04 12:30:14 +02:00
open -- Open a KeePass database file (open <file.kdbx> [<file.key>])
2017-10-03 12:33:02 +02:00
pwck -- Check password quality: pwck <entry|group>
pwd -- Print the current working directory
quit -- Quit this program (EOF and exit also work)
rename -- Rename a group: rename <path to group>
rm -- Remove an entry: rm <path to entry|entry number>
rmdir -- Delete a group (rmdir <group_name>)
save -- Save the database to disk
2017-10-04 12:30:14 +02:00
saveas -- Save to a specific filename (saveas <file.kdbx> [<file.key>])
2017-10-03 12:33:02 +02:00
show -- Show an entry: show [-f] [-a] <entry path|entry number>
stats -- Prints statistics about the open KeePass file
ver -- Print the version of this program
vers -- Same as "ver -v"
xp -- Copy password to clipboard: xp <entry path|number>
xu -- Copy username to clipboard: xu <entry path|number>
xw -- Copy URL (www) to clipboard: xw <entry path|number>
xx -- Clear the clipboard: xx
Type "help <command>" for more detailed help on a command.
2016-09-26 13:50:18 +02:00
kpcli:/> ls
2017-10-04 23:46:27 +02:00
2016-09-26 13:50:18 +02:00
=== Groups ===
eMail/
Internet/
2017-10-04 23:46:27 +02:00
2016-09-26 13:50:18 +02:00
kpcli:/> cd Internet/
kpcli:/Internet> ls
2017-10-04 23:49:27 +02:00
2016-09-26 13:50:18 +02:00
=== Entries ===
2017-10-03 12:33:02 +02:00
0. example.com secure.example.com
1. example.net intra.example.net
2. example.org magic.example.org
2017-10-04 23:46:27 +02:00
2017-10-03 12:33:02 +02:00
kpcli:/Internet> show 2
2016-09-26 13:50:18 +02:00
Path: /Internet
2017-10-03 12:33:02 +02:00
Title: example.org
Uname: baz
Pass:
URL: magic.example.net
Notes: Tarpin secure thing
2016-09-26 13:50:18 +02:00
~~~
2017-10-05 16:37:53 +02:00
Note : le champ «Pass» est invisible mais l'on peut le copier/coller avec la souris.
### Ajouter une entrée
~~~
$ kpcli:/Internet> new
2017-10-04 23:49:27 +02:00
Adding new entry to "/Internet"
Title: example
Username: root
Password: ("g" or "w" to auto-generate, "i" for interactive)
Retype to verify:
URL:
2017-10-04 23:46:27 +02:00
Tags:
Strings: (a)dd/(e)dit/(d)elete/(c)ancel/(F)inish?
Notes/Comments (""):
(end multi-line input with a single "." on a line)
|
Database was modified. Do you want to save it now? [y/N]:
2017-10-04 12:30:14 +02:00
Saved to foo.kdbx
2017-10-03 12:33:02 +02:00
~~~
2017-10-04 11:48:48 +02:00
### Modifier une entrée
2017-10-04 23:46:27 +02:00
~~~
$ kpcli:/Internet> edit 0
~~~
## FAQ
### Multi-utilisateurs
2017-10-04 23:46:27 +02:00
Malheureusement l'utilisation d'un même fichier à plusieurs utilisateurs est mal géré.
L'ouverture d'une base de données avec KeePassX provoque la création d'un fichier .lock empêchant l'ouverture en écriture par un autre utilisateur. Pour détecter cet utilisateur, voir le propriétaire du fichier .lock…