Add a Passphrase to a SSH Private Key

If you generate a SSH private key and would now like to add or modify the passphrase it uses:

#--- Wednesday, November 21, 2018
#--- Make a copy of your private key with no passphrase
cp -frp id_rsa{,_with_pass}

ll id_rsa*
[email protected] 1 jacob  root  1675 Dec 14  2017 id_rsa
[email protected] 1 jacob  root  1675 Dec 14  2017 id_rsa_with_pass

#--- Generate a passphrase with (-p) for the (-f) file
ssh-keygen -p -f id_rsa_with_pass

Enter new passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved with the new passphrase.

#--- The new private key is modified and a passphrase added
ll id_rsa*
[email protected] 1 jacob  root  1675 Dec 14  2017 id_rsa
[email protected] 1 jacob  root  1766 Nov 21 00:09 id_rsa_with_pass

diff --side-by-side id_rsa*
-----BEGIN RSA PRIVATE KEY-----					-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEA3afiLCoGMK0eqhR9VEP3amxr5xa0j8vi7l6Y+L5Ro7K44 |	Proc-Type: 4,ENCRYPTED
9RmiLXOOF9dSMNrALB9hafrbt/OpajUlNcA+072oy+ItciCkiTUxrU8UQ/gV2 |	DEK-Info: AES-128-CBC,6518F33C5DBAE1F51C2BFB428C9313E2
fY2jo4A6WH0C4kHnSynEg+BGmqEAuO0YziR4taIn+lSRB0uy0qKJgWBKLUns0 |
uUXtG6THv+yxHMdOwkMjE8AWBtzEdSOhQGbFs17hdC9GknyIiR6G+O8KnGz91 |	afOoGpL8wdYjsN9XQO/M8boDdDN0BXssXsPSEI34pOCkUNc5z8l9b7YXIQlc/

#--- SSH and set the (-i) identity file
ssh -i id_rsa_with_pass [email protected]
Enter passphrase for key 'id_rsa_with_pass':

#--- Start a new ssh-agent to temporarily store a passphrase
ps -ef | grep [s]sh-agent
  501   999     1   0 12:41AM ??         0:00.06 /usr/bin/ssh-agent -l

ssh-agent -t 60 $SHELL

ps -ef | grep [s]sh-agent
  501   999     1   0 12:41AM ??         0:00.06 /usr/bin/ssh-agent -l
  501  1776  1775   0  2:49AM ??         0:00.00 ssh-agent -t 60 /bin/bash

ssh-add; ssh remote-host 'date'; sleep 30; ssh remote-host 'date'; sleep 30; ssh remote-host 'date'

Enter passphrase for /Users/jacob/.ssh/id_rsa:
Identity added: /Users/jacob/.ssh/id_rsa (/Users/jacob/.ssh/id_rsa)
Wed Nov 21 03:39:33 PST 2018
Wed Nov 21 03:40:04 PST 2018
Enter passphrase for key '/Users/jacob/.ssh/id_rsa':
Wed Nov 21 03:40:39 PST 2018

#--- MacOS add passphrase to your keychain
ssh-add -K

#--- MacOS add to your (~/.ssh/config) add passphrase to keychain automatically
    AddKeysToAgent yes
    UseKeychain yes
    IdentityFile ~/.ssh/id_rsa