I want to write a bash script that:
- establishes an SSH tunnel
- launches a local VNC client (
vncviewer
, the RealVNC viewer in my case) - closes the SSH tunnel once the
vncviewer
exits
Best effort so far:
ssh -L 5900:localhost:5900 <my IP address> -N &
pid=$!
/Applications/VNC\ Viewer.app/Contents/MacOS/vncviewer localhost:5900
kill "$pid"
I couldn't get it to work with open
, though. This works, but the script exits leaving an open tunnel behind:
ssh -L 5900:localhost:5900 <my IP address> -N -f sleep 10
open -a 'VNC Viewer' --args localhost:5900
Using open
seems to be more intuitive and user friendly.