summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2002-12-03 16:33:01 +0000
committerJonas Smedegaard <dr@jones.dk>2002-12-03 16:33:01 +0000
commitbc339dd4d4818fc098104c30cb7cc7dc2f13a8bc (patch)
tree21439e06a851ff456650977af86c9b6a37b434db
parent327e06be0c1e23968e1089ebde74dd79e2369109 (diff)
mksshauth: Separate option parsing and execution. Add header with copyright info.
-rwxr-xr-xmksshauth37
1 files changed, 27 insertions, 10 deletions
diff --git a/mksshauth b/mksshauth
index f6b688e..cbbcb50 100755
--- a/mksshauth
+++ b/mksshauth
@@ -1,23 +1,40 @@
#!/bin/bash
+#
+# /usr/local/bin/mksshauth
+# Copyright 2001-2002 Juri Jensen <juri@xenux.dk> & Jonas Smedegaard <dr@jones.dk>
+#
+# $Id: mksshauth,v 1.2 2002-12-03 16:33:01 jonas Exp $
+#
+# Setup local and remote SSH for non-interactive authorization
+#
-ssh_version=$1
+set -e
+
+prg=`basename $0`
+keytype=$1
host=$2
-case "$ssh_version" in
- 1)
- [ -f ~/.ssh/identity.pub ] || ssh-keygen
- ssh $host "mkdir -p ~/.ssh && echo `cat ~/.ssh/identity.pub` >> ~/.ssh/authorized_keys"
+case "$keytype" in
+ 1|rsa1)
+ keytype=rsa1
+ id_file=identity.pub
+ auth_file=authorized_keys
;;
2|dsa)
- [ -f ~/.ssh/id_dsa.pub ] || ssh-keygen -t dsa
- ssh $host "mkdir -p ~/.ssh && echo `cat ~/.ssh/id_dsa.pub` >> ~/.ssh/authorized_keys2"
+ keytype=dsa
+ id_file=id_dsa.pub
+ auth_file=authorized_keys2
;;
rsa)
- [ -f ~/.ssh/id_rsa.pub ] || ssh-keygen -t rsa
- ssh $host "mkdir -p ~/.ssh && echo `cat ~/.ssh/id_rsa.pub` >> ~/.ssh/authorized_keys2"
+ keytype=rsa
+ id_file=id_rsa.pub
+ auth_file=authorized_keys2
;;
*)
- echo "Usage: $(basename $0) 1|2|dsa|rsa [user@]host"
+ echo "Usage: $prg 1|2|dsa|rsa [user@]host"
exit 1
;;
esac
+
+[ -f ~/.ssh/$id_file ] || ssh-keygen -t $keytype
+ssh $host "mkdir -p ~/.ssh && echo `cat ~/.ssh/$id_file` >> ~/.ssh/$auth_file"