Skip to content

Instantly share code, notes, and snippets.

@adomingues
Created May 28, 2020 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adomingues/56b7af0bc31d992410b81b8a1b786aa7 to your computer and use it in GitHub Desktop.
Save adomingues/56b7af0bc31d992410b81b8a1b786aa7 to your computer and use it in GitHub Desktop.
Add a password to an OpenSSH private key generated without a password
cd .ssh/
mkdir -p ~/.ssh/backup_keys
## backup current keys just in case
for k in id_*; do
cp $k backup_keys/$k"_bak_$(date +"%m_%d_%Y")"
done
## it will ask for a password for every key file
for k in $(ls id_* | grep -v pub); do
echo $k
ssh-keygen -p -f $k
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment