summaryrefslogtreecommitdiff
path: root/mksshauth
diff options
context:
space:
mode:
Diffstat (limited to 'mksshauth')
-rwxr-xr-xmksshauth32
1 files changed, 29 insertions, 3 deletions
diff --git a/mksshauth b/mksshauth
index 4859cac..8666702 100755
--- a/mksshauth
+++ b/mksshauth
@@ -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"