+ hostName=${1:-$(hostname --fqdn)}
+
+ SERVICE=${SERVICE:-"ssh"}
+ userID="${SERVICE}://${hostName}"
+
+ if gpg --list-key ="$userID" > /dev/null 2>&1 ; then
+ failure "Key for '$userID' already exists"
+ fi
+
+ # set key defaults
+ KEY_TYPE=${KEY_TYPE:-"RSA"}
+ KEY_LENGTH=${KEY_LENGTH:-"2048"}
+ KEY_USAGE=${KEY_USAGE:-"auth"}
+ KEY_EXPIRE=${KEY_EXPIRE:-"0"}
+ cat <<EOF
+Please specify how long the key should be valid.
+ 0 = key does not expire
+ <n> = key expires in n days
+ <n>w = key expires in n weeks
+ <n>m = key expires in n months
+ <n>y = key expires in n years
+EOF
+ read -p "Key is valid for? ($KEY_EXPIRE) " KEY_EXPIRE; KEY_EXPIRE=${KEY_EXPIRE:-"0"}