summaryrefslogtreecommitdiffstats
path: root/bin/ssh-keygen-new-host.sh
blob: 4340368266c24303401e431bc45a19b8002240b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh

set -e

if [ -z "${@}" ]
then
	echo -n "Hostnames [FQDN,HOSTNAME]:"
	read _HOSTNAMES
else
	_HOSTNAMES="${@}"
fi

_FQDN="$(echo ${_HOSTNAMES} | awk -F, '{ print $1 }')"
_HOSTNAME="$(echo ${_HOSTNAMES} | awk -F, '{ print $2 }')"

echo -n "Date [365d]: "
read _DATE

_DATE="${_DATE:-365d}"

_CA="../ca/$(basename ../ca/*.pub .pub)"

ssh-keygen -N "" -t rsa -b 4096 -f ${_FQDN} -C sysadmin@${_FQDN} 2>&1 | tee ${_FQDN}.txt

ssh-keygen -s ${_CA} -I $(basename ${_CA}) -h -n ${_HOSTNAMES} -V +${_DATE} ${_FQDN}