2019-09-13 06:23:12 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e;
|
|
|
|
|
2023-01-25 08:42:22 +00:00
|
|
|
check_required() {
|
|
|
|
type openssl &> /dev/null || { echo "Requiring 'openssl' but it's not installed"; exit 1; }
|
|
|
|
type ssh-keygen &> /dev/null || { echo "Requiring 'ssh-keygen' but it's not installed"; exit 1; }
|
|
|
|
}
|
|
|
|
|
2019-09-13 06:23:12 +00:00
|
|
|
name=$1;
|
|
|
|
encryption=$2;
|
|
|
|
|
|
|
|
if [[ -z "${name}" ]]; then
|
|
|
|
echo "Usage: ssh-keygen-rsa <name> [<encryptionKeySize>]"
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z ${encryption} ]]; then
|
2022-06-13 09:31:59 +00:00
|
|
|
encryption=4096;
|
2019-09-13 06:23:12 +00:00
|
|
|
fi
|
|
|
|
|
2023-01-25 08:42:22 +00:00
|
|
|
check_required
|
|
|
|
|
2019-09-13 06:23:12 +00:00
|
|
|
openssl genrsa -out "${name}" "${encryption}"
|
|
|
|
ssh-keygen -y -f "${name}" > "${name}.pub"
|