#!/bin/bash -e hash -r setglobal PROG = $(0##*/) proc usage{ local ret=$(1:-0) if test $ret -eq 0 { exec 3>&1 } else { exec 3>&2 } cat <&3 ${PROG} path-to-keyfile EoF exec 3>&- exit ${ret} } setglobal keypath = $(1:-$HOME/.ssh/id_rsa.bcpc) setglobal distroot = '/var/www/cobbler/pub/keys' yes | ssh-keygen -N '' -f $(keypath) if test -n $(SUDO_UID) { chown $(SUDO_UID) $(keypath) } install -D "$(keypath).pub" "$(distroot)/root"