key-generation.sh 553 B

12345678910111213
  1. #!/bin/bash
  2. #--Snippet to generate ssh keys------------------------------------------------
  3. keyUser="USERNAME__PASTE_HERE"
  4. keyFQDN="FQDN__PASTE_HERE" #full hostname
  5. #------------------------------------------------------------------------------
  6. keyType="ed25519"
  7. #keyType="rsa"
  8. keyDate=`date +%F` # format yyyy-mm-dd
  9. keyPass=`openssl rand -base64 21` # multiple of 3 characters to avoid padding
  10. keyName="id_"$keyType"_"$keyUser"_"$keyFQDN"_"$keyDate
  11. ssh-keygen -t ed25519 -C $keyName -N $keyPass -f ./$keyName
  12. ls $keyName*
  13. echo $keyPass && unset keyPass