diff options
author | Jonas Smedegaard <dr@jones.dk> | 2002-12-03 17:29:39 +0000 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2002-12-03 17:29:39 +0000 |
commit | c4095a43968ba3cedc0df1dc7c8f24b5363952b0 (patch) | |
tree | 5f8548b18d2811973514b90637b62bbe43fc4861 /mksshauth | |
parent | e6b0217dc29dced82c698aa5f41a2a2f61660618 (diff) |
mksshauth: Support for extra options. Vastly improved error handling.
Diffstat (limited to 'mksshauth')
-rwxr-xr-x | mksshauth | 32 |
1 files changed, 29 insertions, 3 deletions
@@ -4,7 +4,7 @@ # Copyright 2000-2001 Juri Jensen <juri@xenux.dk> # Copyright 2002 Juri Jensen <juri@xenux.dk> & Jonas Smedegaard <dr@jones.dk> # -# $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" |