3

I have a VNC server (x11vnc) configured to allow me to log into the machine at the local display (:0) via SSH tunnel, following the instructions here.
My question: is there a way to create the tunnel AND launch vncviewer with a single command/script?

Here's how I'm launching x11vnc from /etc/gdm/Init/Default:

x11vnc -localhost -nopw -ncache 0 -o /var/log/x11vnc.log -forever -bg

Edit: please note that in this way x11vnc starts from gdm, so that I can log into the local session myself.

(Server and client: Xubuntu 9.04)

Joril
  • 1,610
  • 1
  • 21
  • 28

2 Answers2

6

The vncviewer can connect on it's own through SSH, so a shorter command would be:

vncviewer -via username@hostname.tld localhost:x

On the above, x is your local display (0, 1...).

  • Very convenient, thanks :) I still have the "disconnects after login" problem though.. Maybe the only way for that is to use two terminals.. – Joril May 05 '09 at 11:50
  • 2
    Setting up VNC as a remote terminal service requires a bit of footwork, but you might be better off installing the tightvnc package instead. Not only does it have slightly better options but it also supports compression, a must-have for remote work over slow internet connections (tunneling with SSH, of course). Also, I believe that there is a command option that discourages disconnects...can't recall ATM... – Avery Payne May 05 '09 at 12:53
0

Note: untested

try this

ssh host -f -L5900:localhost:5900 "sleep 10000000000" && vncviewer localhost:5900
Dave Cheney
  • 18,567
  • 8
  • 49
  • 56
  • This works fine, thanks! I'll look for a way to close ssh when the vnc connection gets closed.. Anyway, now the only remaining problem is logging in.. When I enter user and password vncviewer exits and if I try to reconnect, the login screen is still there.. If I use two terminal windows instead (one for the SSH tunnel and one for VNC) I can login just fine.. :/ – Joril May 05 '09 at 09:43