#!/usr/bin/env bash

BITS=512
TYPE=ed25519
KEY_FILE="$HOME/.ssh/eole"
OPT=""

function usage() {
    echo "Usage: $0 [-c comment] [-f key_file]" 1>&2;
	exit 1;
}

while getopts ":c:f:" option; do
    case "${option}" in
        c)
            OPT="-C ${OPTARG}"
            ;;
        f)
            KEY_FILE=${OPTARG}
            ;;
        *)
            usage
            ;;
    esac
done
shift $((OPTIND-1))

if [ -f "$KEY_FILE" ]; then
    echo "La clé $KEY_FILE existe déjà"
    exit 1
fi
/usr/bin/ssh-keygen -N "" -b "$BITS" -t "$TYPE" -f "$KEY_FILE" $OPT
