Allow for specification of whether to check keyserver.
authorJameson Graef Rollins <jrollins@phys.columbia.edu>
Mon, 16 Jun 2008 18:07:33 +0000 (14:07 -0400)
committerJameson Graef Rollins <jrollins@phys.columbia.edu>
Mon, 16 Jun 2008 18:07:33 +0000 (14:07 -0400)
Update proxy command to check keyserver if host not found in known_hosts.

src/monkeysphere-ssh-proxycommand

index 417d0131d4ad61d82e77f437806590c460d336b4..ec162ab8c62985d92bf82eb0e8a0eccb120abc6b 100755 (executable)
 HOST="$1"
 PORT="$2"
 
+usage() {
+cat <<EOF >&2
+usage: ssh -o ProxyCommand="$(basename $0) %h %p" ...
+EOF
+}
+
+log() {
+    echo "$@" >&2
+}
+
+if [ -z "$HOST" ] ; then
+    log "host must be specified."
+    usage
+    exit 1
+fi
+if [ -z "$PORT" ] ; then
+    log "port must be specified."
+    usage
+    exit 1
+fi
+
+# check for the host key in the known_hosts file
+hostKey=$(ssh-keygen -F "$HOST")
+
+# if the host key is not found in the known_hosts file,
+# check the keyserver
+if [ -z "$hostKey" ] ; then
+    CHECK_KEYSERVER="true"
+fi
+
 # update the known_hosts file for the host
 monkeysphere update-known-hosts "$HOST"