Thursday, December 27, 2007

SSH tunnel over AFP

Reference to: Remotely Managing Your Mac Using AFP and SSH

#!/bin/sh
# script to make ssh tunnel and then connect to afp host
#
# Jan 02 2004 - W Penn - creation
#

LOCAL_PORT=10548;
Tunnels

LOCAL_HOST=127.0.0.1;
TARGET_PORT=548;

TARGET_HOST=windswept.dyndns.org;


ssh -L $LOCAL_PORT:$TARGET_HOST:$TARGET_PORT -f -N $LOCAL_HOST;

open afp://localhost:$LOCAL_PORT/;

clear
TUN=`lsof -i:$LOCAL_PORT -Fp | head -1| sed s/p//`
echo IMPORTANT: Leave this Terminal window open during your AFP session.
echo When you finish your AFP session, press the ENTER key in this window.
echo This will manually close down your SSH tunnel to the remote computer.
read answer
clear
kill $TUN
echo SSH tunnel closed. You now can close this Terminal window.