#!/bin/sh -e

# monkeysphere-ssh-proxycommand: MonkeySphere ssh ProxyCommand hook
#
# The monkeysphere scripts are written by:
# Jameson Rollins <jrollins@fifthhorseman.net>
#
# They are Copyright 2008, and are all released under the GPL, version 3
# or later.

# This is meant to be run as an ssh ProxyCommand to initiate a
# monkeysphere known_hosts update before an ssh connection to host is
# established.  Can be added to ~/.ssh/config as follows:
#  ProxyCommand monkeysphere-ssh-proxycommand %h %p

HOST="$1"
PORT="$2"

# update the known_hosts file for the host
monkeysphere update-known-hosts "$HOST"

# exec a netcat passthrough to host for the ssh connection
exec nc "$HOST" "$PORT"