SERVER-1>vncserver New 'X' desktop is SERVER-1:12 Starting applications specified in /home/USER/.vnc/xstartup Log file is /home/USER/.vnc/SERVER-1:12.log |
That means your vnc session id in SERVER-1 is 12.
which means that your vnc ports are 5812 for the web version and 5912
for the vncviewer.
(the web vnc are always 58xx while the vncviewer are 59xx,
where xx is the session id).
NOTE:The rest of the howto is going to assume that the session is on SERVER-1 and has session id 12. If you are connecting to another session or/and to another server, make the appropriate changes.
After you started the vnc on SERVER-1, to connect to your session, you can do it via 2 ways.
Via the web
Via vncviewer
vnc over ssh port forwarding
Let's say you want to connect to the same SERVER-1:12 vnc sessions that we started earlier, except you can't reach SERVER-1. You can only reach SERVER-2 from where you are.
Well, we can tunnel SERVER-1's vnc session via ssh over to SERVER-2, and that way, we only have to connect to SERVER-2 to be able to access SERVER-1's vnc.
How do we do that?
First, from SERVER-2, we'll have to establish a ssh connection to SERVER-1. Now let's assume joe has an account on both machines.
SERVER-2>ssh -C -g -L 5901:SERVER-1:5912 joe@SERVER-1 joe@SERVER-1's password: Last login: Wed Jul 7 14:38:48 2004 from SERVER-2.in Sun Microsystems Inc. SunOS 5.8 Generic Patch October 2001 2004.07.07-14:39:08 joe@SERVER-1[2001]~ > |
So we see that joe has logged in to SERVER-1 from SERVER-2. the 5901:SERVER-1:5912 statement is telling us that we are forwarding the 5912 (vnc session 12) to 5901 ( vnc session 1 ).
Now we just launch vncviewer, and connect to SERVER-2:1
You'll see that you are not connected to SERVER-2, but to SERVER-1 instead.