Deprecated: Grav\Common\Grav::setup(): Implicitly marking parameter $environment as nullable is deprecated, the explicit nullable type must be used instead in /home/itametis/university/system/src/Grav/Common/Grav.php on line 189

Deprecated: Grav\Common\Grav::header(): Implicitly marking parameter $response as nullable is deprecated, the explicit nullable type must be used instead in /home/itametis/university/system/src/Grav/Common/Grav.php on line 478

Deprecated: Grav\Common\Grav::fireEvent(): Implicitly marking parameter $event as nullable is deprecated, the explicit nullable type must be used instead in /home/itametis/university/system/src/Grav/Common/Grav.php on line 541

Deprecated: Return type of Pimple\Container::offsetExists($id) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/itametis/university/vendor/pimple/pimple/src/Pimple/Container.php on line 133

Deprecated: Return type of Pimple\Container::offsetGet($id) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/itametis/university/vendor/pimple/pimple/src/Pimple/Container.php on line 98

Deprecated: Return type of Pimple\Container::offsetSet($id, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/itametis/university/vendor/pimple/pimple/src/Pimple/Container.php on line 79

Deprecated: Return type of Pimple\Container::offsetUnset($id) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/itametis/university/vendor/pimple/pimple/src/Pimple/Container.php on line 143

Deprecated: Grav\Common\Debugger::profile(): Implicitly marking parameter $message as nullable is deprecated, the explicit nullable type must be used instead in /home/itametis/university/system/src/Grav/Common/Debugger.php on line 543

Deprecated: Grav\Common\Debugger::stopProfiling(): Implicitly marking parameter $message as nullable is deprecated, the explicit nullable type must be used instead in /home/itametis/university/system/src/Grav/Common/Debugger.php on line 584

Deprecated: Grav\Common\Debugger::addEvent(): Implicitly marking parameter $time as nullable is deprecated, the explicit nullable type must be used instead in /home/itametis/university/system/src/Grav/Common/Debugger.php on line 775
Comment ajouter/retirer un mot de passe à une clef privée ? | Itametis Université
Publié le 11/02/2017, rédigé par Gaulthier LALLEMAND

OpenSSL

Comment ajouter/retirer un mot de passe à une clef privée ?

Prérequis : disposer d'une clef privée.

Je dispose d'une clef privée Serveur.key dépourvue de mot de passe.

Ajouter un mot de passe

Pour lui ajouter un mot de passe, je n'ai qu'à lancer la commande suivante :

openssl [KEY_TYPE] [ALGO] -in Serveur.key -out Serveur.key.protected

Avec KEY_TYPE la méthode utilisée pour générer la clef :

Et avec ALGO l'algorithme utilisé pour chiffrer la clef :

Ainsi, pour chiffrer une clef RSA avec AES256 :

openssl rsa -aes256 -in Serveur.key -out Serveur.key.protected

Puis j'entre le mot de passe :

writing RSA key
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:

Retirer le mot de passe

Je souhaite maintenant retirer le mot de passe de ma clef :

openssl [KEY_TYPE] -in Serveur.key.protected -out Serveur.key

Pour une clef RSA cela donne :

openssl rsa -in Serveur.key.protected -out Serveur.key

Changer le mot de passe

Si ma clef est déjà protégée par un mot de passe, mais que je désire le changer, je peux procéder en une seule étape :

openssl [KEY_TYPE] [ALGO] -in Serveur.key.protected -out Serveur.key.protected