key-generation.sh 567 B

1234567891011121314
  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 $keyType -C $keyName -N $keyPass -f ./$keyName
  12. ls $keyName*
  13. echo $keyPass > $keyName.pass
  14. unset keyPass