Skip to content

Instantly share code, notes, and snippets.

@simlun
Created July 30, 2014 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simlun/50a10c4ea96ee7c62da0 to your computer and use it in GitHub Desktop.
Save simlun/50a10c4ea96ee7c62da0 to your computer and use it in GitHub Desktop.
Connect to an x11vnc server over an SSH tunnel from a Mac
#!/bin/sh
# Tip: An executable script given a `.command` suffix will be double-clickable on Mac OS X
REMOTE_SSH_USER=pi
REMOTE_SSH_HOST=192.168.0.17
REMOTE_VNC_SERVER_PORT=5900
LOCAL_VNC_PORT=5901
# This is the RealVNC Viewer, works with Chicken of the VNC too
LOCAL_VNC_CLIENT=/Applications/VNC\ Viewer.app/Contents/MacOS/vncviewer
ssh -f -L 127.0.0.1:$LOCAL_VNC_PORT:localhost:$REMOTE_VNC_SERVER_PORT $REMOTE_SSH_USER@$REMOTE_SSH_HOST x11vnc -safer -localhost -rfbport $REMOTE_VNC_SERVER_PORT -nopw -once -display :0 -timeout 60 -no6 -noipv6 && sleep 3 && $LOCAL_VNC_CLIENT 127.0.0.1:$LOCAL_VNC_PORT
@Klaswh
Copy link

Klaswh commented Aug 21, 2017

You need to put LOCAL_VNC_CLIENT between quotes. So the line should bee:

ssh -f -L 127.0.0.1:$LOCAL_VNC_PORT:localhost:$REMOTE_VNC_SERVER_PORT $REMOTE_SSH_USER@$REMOTE_SSH_HOST x11vnc -safer -localhost -rfbport $REMOTE_VNC_SERVER_PORT -nopw -once -display :0 -timeout 60 -no6 -noipv6 && sleep 3 && "$LOCAL_VNC_CLIENT" 127.0.0.1:$LOCAL_VNC_PORT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment