diff options
Diffstat (limited to 'scripts/mkreq')
-rwxr-xr-x | scripts/mkreq | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/scripts/mkreq b/scripts/mkreq index 4493867..44aaddc 100755 --- a/scripts/mkreq +++ b/scripts/mkreq @@ -1,6 +1,5 @@ #!/bin/sh -host="$1"; shift ca_host="ca.sunet.se" ca_name="infra" type="" @@ -16,20 +15,27 @@ Usage: mkreq [-v] [-s*] [-c] [-C <ca host>] [-N <ca name>] [--] <fqdn> -c request client cert -C ca host (ca.sunet.se) -N ca name (infra) - + <fqdn> fully qualified name of host " 1>&2 } +if [ "x$1" = "x" ]; then + usage + exit 1 +fi + { while test $# -gt 0; do case "$1" in -s) type="server" + shift ;; -c) type="client" + shift ;; -C) ca_host="$2" @@ -46,19 +52,33 @@ Usage: mkreq [-v] [-s*] [-c] [-C <ca host>] [-N <ca name>] [--] <fqdn> --) break ;; + *) + echo $1 | grep -q '^-' || break # found the fqdn + echo "$0: Unknown option $1" + echo "" + usage + exit 1 esac - shift done } +host="$1" + +if [ "x$host" = "x" ]; then + echo "$0: No fqdn supplied" + echo "" + usage + exit 1 +fi + if [ -d $host -a -z $type ]; then type="server" fi cfg=`mktemp` -key="/tmp/$host.key" -csr="/tmp/$host.csr" +key=`mktemp` +csr=`mktemp` trap 'rm -f $cfg' EXIT @@ -90,6 +110,12 @@ git add "$reqs/$host.csr" && git commit -m "certification request for $host from if [ -d $host ]; then ssh root@$host mkdir -p /etc/ssl/private && scp "$key" "root@$host:/etc/ssl/private/${host}_${ca_name}.key" && rm -f "$key" && echo "** private key given to $host" || echo "** private key left in $key - should be in root@$host:/etc/ssl/private/${host}_${ca_name}.key" +else + echo "" + echo "** Generated the following RSA key, keep it safe:" + cat $key + rm -f $key + echo "" fi echo "** successfully generated key and certification request for $host from $ca_host:$ca_name" |