key-generation.sh 605 B

123456789101112131415
  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. keyPass=`openssl rand -base64 21` # multiple of 3 characters to avoid padding
  9. keyPass"" # empty for no passphrase
  10. keyDate=`date +%F` # format yyyy-mm-dd
  11. keyName="id_"$keyType"_"$keyUser"_"$keyFQDN"_"$keyDate
  12. ssh-keygen -t $keyType -C $keyName -N "$keyPass" -f ./$keyName
  13. ls $keyName*
  14. echo $keyPass > $keyName.pass
  15. unset keyPass