Skip to content

Instantly share code, notes, and snippets.

@JorgenEvens
Created August 12, 2013 20:20
Show Gist options
  • Save JorgenEvens/6214764 to your computer and use it in GitHub Desktop.
Save JorgenEvens/6214764 to your computer and use it in GitHub Desktop.
Connects to a VNC console on a xen host
#!/bin/sh
HOST=$1
PORT=$2
RUN=true
SOCK=`mktemp -t xenvnc.$HOST.$PORT.XXX`
rm $SOCK
ssh $HOST -f -q -S $SOCK -L $PORT:localhost:$PORT sleep 1d
close_connection() {
RUN=false
}
trap close_connection 1 2 3 15
while $RUN
do
vncviewer localhost:$PORT 2> /dev/null
done
echo "Closing ssh connection ($SOCK)"
ssh -S $SOCK -O exit $HOST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment