Merge commit 'jrollins/master'
[monkeysphere.git] / src / monkeysphere-ssh-proxycommand
index 417d0131d4ad61d82e77f437806590c460d336b4..4b90a0d21fe5e884335a43e277c96473d760c45c 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 found in the known_hosts file,
+# don't check the keyserver
+if [ "$hostKey" ] ; then
+    CHECK_KEYSERVER="false"
+else
+    CHECK_KEYSERVER="true"
+fi
+export CHECK_KEYSERVER
+
 # update the known_hosts file for the host
 monkeysphere update-known-hosts "$HOST"