Tunneling of VNC over ssh in one command

published Mar 27, 2014 03:35   by admin ( last modified Jan 03, 2015 12:53 )

Well actually two, but you stick them in one file that gets executed in bash:

ssh -fN  -L 5900:localhost:5900 remotserver.example.com
vncviewer -encoding tight -quality 5 localhost:0

 

The -N switch prevents commands to be sent to the remote host, the -f switch allows the terminal to come back and prompt for a vnc password that is triggered by the second line.

Warning: Haven't figured out how to exit cleanly. However the top rated answer here might do the trick:

Bash script to setup a temporary SSH tunnel - Stack Overflow