From c4095a43968ba3cedc0df1dc7c8f24b5363952b0 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Tue, 3 Dec 2002 17:29:39 +0000 Subject: mksshauth: Support for extra options. Vastly improved error handling. --- mksshauth | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'mksshauth') diff --git a/mksshauth b/mksshauth index 4859cac..8666702 100755 --- a/mksshauth +++ b/mksshauth @@ -4,7 +4,7 @@ # Copyright 2000-2001 Juri Jensen # Copyright 2002 Juri Jensen & Jonas Smedegaard # -# $Id: mksshauth,v 1.3 2002-12-03 16:35:45 jonas Exp $ +# $Id: mksshauth,v 1.4 2002-12-03 17:29:39 jonas Exp $ # # Setup local and remote SSH for non-interactive authorization # @@ -12,10 +12,32 @@ set -e prg=`basename $0` + +if [ $# \< 2 ]; then + echo "ERROR: Wrong arguments! (Use '$prg --help' for help)" + exit 1 +fi keytype=$1 host=$2 +shift +shift +options=$@ case "$keytype" in + --help|-h) + echo "$prg: Setup local and remote SSH for non-interactive authorization." + echo + echo "Usage: $prg keytype [user@]host [options]" + echo + echo "Options:" + echo " keytype: SSH key type, either rsa1, rsa, dsa, 1 or 2." + echo " rsa1 is for SSHv1, rsa and dsa is for SSHv2. 1 and 2 are" + echo " aliases for rsa1 and dsa. dsa (or 2) is recommended." + echo " user: User id on remote host. Default is same as local user." + echo " host: Hostname of remote host." + echo " options: Options to prepend the authorization key (read 'man sshd')." + exit 0 + ;; 1|rsa1) keytype=rsa1 id_file=identity.pub @@ -32,10 +54,14 @@ case "$keytype" in auth_file=authorized_keys2 ;; *) - echo "Usage: $prg 1|2|dsa|rsa [user@]host" + echo "ERROR: Wrong keytype! (Use '$prg --help' for help)" exit 1 ;; esac +if [ -n "$options" ]; then + options="$options " +fi + [ -f ~/.ssh/$id_file ] || ssh-keygen -t $keytype -ssh $host "mkdir -p ~/.ssh && echo `cat ~/.ssh/$id_file` >> ~/.ssh/$auth_file" +ssh $host "mkdir -p ~/.ssh && echo '$options'`cat ~/.ssh/$id_file` >> ~/.ssh/$auth_file" -- cgit v1.2.3