#!/bin/bash # # Generate keypairs. # # This script is just a wrapper to easily generate keys for # automated systems. # # Generate a keypair, ssh version function genpair_ssh { echo "Make sure that $homedir is atop of an encrypted volume." read -p "Hit ENTER to continue." prompt # TODO: programatically enter blank passphrase twice ssh-keygen -t dsa -f $homedir/id_dsa -C "root@$hostname" echo "Now make sure to save this key in a safe location." echo "You can export it by securely copying $contents to $hostname." } # Generate a keypair, gpg version function genpair_gpg { echo "Make sure that $homedir is atop of an encrypted volume." read -p "Enter password for the private key: " passphrase # TODO: insert 279 random bytes gpg --homedir $homedir --gen-key < " exit 1 elif [ -e "$homedir" ]; then echo "Folder $homedir already exists, leaving" exit 1 fi # Prepare mkdir -p $homedir && chmod 700 $homedir if [ "$?" != "0" ]; then echo "Error setting up $homedir" exit 1 fi # Dispatch genpair_$keytype