# -*-shell-script-*- # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant) # Monkeysphere host import-key subcommand # # The monkeysphere scripts are written by: # Jameson Rollins # Jamie McClelland # Daniel Kahn Gillmor # # They are Copyright 2008-2009 and are all released under the GPL, # version 3 or later. import_key() { local sshKeyFile local hostName local domain local userID sshKeyFile="$1" hostName="$2" # check that key file specified if [ -z "$sshKeyFile" ] ; then failure "Must specify ssh key file to import, or specify '-' for stdin." fi # use the default hostname if not specified if [ -z "$hostName" ] ; then hostName=$(hostname -f) || failure "Could not determine hostname." # test that the domain is not obviously illegitimate domain=${foo##*.} case $domain in 'local'|'localdomain') failure "Host domain '$domain' is not legitimate. Aborting key import." ;; esac # test that there are at least two parts if (( $(echo "$hostName" | tr . ' ' | wc -w) < 2 )) ; then failure "Host name '$hostName' is not legitimate. Aborting key import." fi fi userID="ssh://${hostName}" if [ "$PROMPT" = "true" ] ; then cat <