Last active
September 17, 2019 16:15
-
-
Save jackhftang/749ea0356ebdcb6ee1ae0ec272caaadc to your computer and use it in GitHub Desktop.
bash script for vnc over ssh tunnel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#HOST='tahufa@cube.jackhftang.com' | |
HOST='me@cube.jackhftang.com' | |
SOCK='/tmp/ssh_tunnel_vnc_cube.sock' | |
vncviewer='/Applications/TigerVNC Viewer 1.7.1.app/Contents/MacOS/TigerVNC Viewer' | |
PORT=${1:-5900} | |
## open socket | |
ssh -f -N -C -X -L 5900:127.0.0.1:$PORT -o ExitOnForwardFailure=yes -M -S $SOCK $HOST | |
if [ $? -eq 0 ]; then | |
echo "ssh tunnel started successfully" | |
else | |
echo "ssh tunnel failed to start"; | |
exit 1 | |
fi | |
## start vncviewer | |
"$vncviewer" -FullScreen -DotWhenNoCursor=1 localhost:5900 | |
## close socket | |
ssh -S $SOCK -O exit $HOST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment