dotfiles/bin/vncsconnect

14 lines
376 B
Bash
Executable file

#!/usr/bin/env sh
if [ -z "$1" ]; then
>&2 echo "provide ssh host name"
exit 1
else
ssh_host=$1
fi
remote_port=${2:-5900}
local_port=$((remote_port + 4000))
ssh -O check -- "$ssh_host"
ssh -f -N -L "${local_port}:localhost:${remote_port}" -- "$ssh_host" || exit
wlvncc -- localhost "$local_port"
ssh -O cancel -L "${local_port}:localhost:${remote_port}" -- "$ssh_host"