I have a setup of three machines.

Machine A runs a vncserver and an ssh server, Machine B runs a vncviewer, Machine C runs an ssh client.

The vncviewer on B connects to the vnc server on A.

The ssh client on C connects to the ssh server on A.

Is it possible that from the ssh session in C I spawn a process ( say xclock) on A so that the process shows up in the vncviewer on B's screen. Basically I am looking for the value to set DISPLAY variable to so that this can be achieved.

PS : Please reword the title of my question if you find that it doesn't appropriately describe my question


1 Answer 1


Yes. Just set DISPLAY to the same value as in the VNC session. (Start a terminal window in the VNC session and type echo $DISPLAY. That's the value you need to use.)

  • okay that works, but only after I do xhost + on the machine with vncviewer :( Is there any work around for that ?
    – AnkurVj
    Apr 17, 2012 at 10:26
  • Is the user running the vncserver the same as the user logged in via ssh? You can grant access to only the necessary user; read up on man xhost.
    – cjm
    Apr 17, 2012 at 10:44
  • @AnkurVj without opening up access with xhost, you would have to transfer the x authorization cookie to server C so that it can properly authenticate.
    – phemmer
    Apr 17, 2012 at 10:59
  • actually I don't mind insecure environment, as I am running experiments. I just wanted that once I start vncviewer on C I should be able to forward X on that terminal without having to type any xhost command
    – AnkurVj
    Apr 17, 2012 at 11:01
  • 1
    @AnkurVj After re-reading the question, this shouldnt be required (and neither should running xhost). However to answer, xhost + removes all authorization checking meaning that absolutely anyone can connect to the X11 display (security hole). transferring the X cookie makes it so that you can authenticate properly and not have to open X11 to the world. If you want more elaboration, should probably just open up another question. Goes far beyond the scope of a comment.
    – phemmer
    Apr 17, 2012 at 12:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .