Add or remove passphrase on SSH key

You can add or remove passphrase for your SSH private keys after creating your key pairs without creating a new key pair by using any of the following methods;

  1. Interactive ssh-keygen
    $ ssh-keygen -p
    Enter file in which the key is (/home/user/.ssh/id_rsa):
    Enter new passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved with the new passphrase.
  2. Inline ssh-keygen
    $ ssh-keygen -p -P old_passphrase -N new_passphrase -f /home/user/.ssh/id_rsa
    Your identification has been saved with the new passphrase.
  3. openssl
    $ openssl rsa -in ~/.ssh/id_rsa -out ~/.ssh/id_rsa_new
    Enter pass phrase for /home/user/.ssh/id_rsa:
    writing RSA key

Sign up for Complete Secure Shell Course and many other great courses on Udemy to learn more.


Written by Mohd Shakir Zakaria. Last updated on 2019-02-12