Help for Using VNC
Virtual Network Computing (VNC) is a Linux remote desktop. You need an ENCS account so that you can log in to computation.encs.concordia.ca You will need to (a) use a Putty terminal to start a vnc server, (b), use a second putty terminal to make a tunnel, then (c) run a VNC viewer on your local machine. Doing this with Linux or OSX is described later. For Windows, get Putty and VNC Viewer from https://www.putty.org/ https://www.realvnc.com/ The viewer is vnc-4.1.3.exe (32 bit) or VNC64.exe (64 bit). Side note: it can be useful to transfer files back and forth between ENCS and your PC. This can be done with drag and drop, using WinSCP at https://sourceforge.net/projects/winscp/ ******************************************** **** VNC server, runs on ENCS machine ****** ******************************************** Step 1: Use a command-line terminal (Linux or OSX) or a Putty terminal (Windows) to log in to computation.encs.concordia.ca. It will redirect you to one of many possible machines; the least busy one. In this case let's assume you get sent to poise.encs. Step 2: Start the VNC server. On the poise.encs command line, type vncserver The vncserver will say something like this: New 'poise.encs.concordia.ca:2 ' desktop is poise.encs.concordia.ca:2 That "2" and "poise" is **very important** information. The "poise" machine is running the server. The "2" means that you've been given port 5902. It could be any number. VNC works on ports 5901, 5902, 5903,... and up. When there are several users, the server picks the next available port. There are sometimes useful messages in the log file .vnc/poise.encs.concordia.ca:2.log. Step 3: VNC will ask you to make up a VNC password; this is different from the login password. You can use vncpasswd to reset the password. Or, rm ~/.vnc/passwd. Step 4: When you're finished working, kill the vncserver. vncserver -kill :2 You can restart it on 5902 with vncserver :2 Important: be considerate and kill your server when you are done, so that other people can use the port. ******************************************** *** VNC tunnel for Windows local machine *** ******************************************** Step 1: Start a second Putty terminal. We will use it to make a tunnel. Go to 'Configuration-> Session' and for Hostname put: myusername@computation.encs.concordia.ca ssh port 22 Step 2: In Putty 'Configuration-> Connection-> SSH Tunnels' set up port forwarding Source port=5902 Destination=poise.encs.concordia.ca:5902 Press Add. In the Forwarded Ports box you should now see: L5902 poise.encs.concordia.ca:5902 Step 3: Press Open to start the terminal. Note 1: For the destination, never put a user name, e.g. myusername@poise Note 2: In this example the VNC server is running on poise.encs, so the tunnel destination should be poise.encs.concordia.ca:5902 Note 3: Do not use computation.encs.concordia.ca:5902 for the tunnel destination. Tunneling will fail if the second terminal's login gets redirected to something other than poise. Summary: The purpose of the 1st terminal is to start the VNC server. The purpose of the 2nd terminal is to provide tunneling to the server. ******************************************** **** VNC viewer, Windows local machine ***** ******************************************** Step 1: Run the VNC Viewer executable file vnc-4.1.3.exe (32 bit) or VNC64.exe (64 bit) on your PC. Ask for a connection to localhost::5902 and give your VNC password. Step 2: At the end of your work, kill the VNC server. First, close the running applications. Then press the red "X" in the upper right corner of the frame, or press F8. Then, use the Putty terminal to kill the vncserver 5902 with vncserver -kill :2 Important: be considerate and kill your server when you are done, so that other people can use the port. ******************************************** **** VNC tunnel, Linux local machine ******* ******************************************** Open a tunnel from port 5902 on your local machine (localhost) to port 5902 on the remote machine poise.encs.concordia.ca In an xterminal, type me@local_machine/> ssh me@poise.encs.concordia.ca -f -N -C \ -L 5902:poise.encs.concordia.ca:5902 ******************************************** **** VNC viewer, Linux local machine ******* ******************************************** You might have /usr/bin/vncviewer. If not, then install it. More recently (2014) there is /usr/bin/vinagre. To run the vncviewer, on the local machine type (note that 5902 = 2) me@local_machine/> vncviewer localhost:2 With a gnome desktop, you might find the vncviewer or vinagre at Applications ->Internet ->Remote Desktop Connection --or maybe-- Applications -> Accessories -> VNC Viewer and in this example, use the address/port localhost::5902 Important: be considerate and kill your server when you are done, so that other people can use the port. ******************************************** *** Tunnel and VNC viewer, Macintosh OSX *** ******************************************** Open a tunnel from port 5902 on your local machine (localhost) to port 5902 on the remote machine poise.encs.concordia.ca In an xterminal, type ssh -p 22 myusername@poise.encs.concordia.ca \ -L 5902:poise.encs.concordia.ca:5902 then use the Real VNC viewer for mac and enter localhost::5902 ******************************************** **** VNC Hints ***************************** ******************************************** **** Favorite port? When starting the VNC server you can use vncserver :8 to get port 5908. It it is busy, the request will be denied. You can always see who is on what port by typing ps aux | grep vnc **** Screen size Right-click on your local machine's desktop and find out the resolution. Suppose it says something like 1366x768; typical for a laptop. You can then use vncstart :8 -geometry 1300x700 to pretty much fill up the screen. It is highly advisible to undersize by a little bit. **** Screen saver You will get asked for your password after 10 minutes of idle time. You can stop this by disabling the screensaver in System->Preferences->Screensaver You can speed up the VNC response by using a solid color desktop instead of a picture. Change it with a right-click on the remote desktop background. **** VNC crash If the vncviewer or server crashes (this is rare) you will have to delete some of your files in /tmp. For example, with VNC port 5902 use rm -f /tmp/.X2-lock; rm -f /tmp/.X11-unix/X2 In your own .vnc/ directory delete the file .vnc/poise.encs.concordia.ca:2.pid After a crash there might be processes hanging around, called bonobo, gam_server, gnome-panel, gconfd. Find them and kill them, e.g. use: pkill -9 -u $USER bonobo-activation-server pkill -9 -u $USER gam_server pkill -9 -u $USER gnome-panel pkill -9 -u $USER gconfd ******************************************** ****** Using the Right Window Manager ****** ******************************************** If the remote desktop shows no usable functions, e.g. a terminal, you probably have a problem with the window manager startup file .vnc/xstartup The following works for me in ENCS; it uses the Motif window manager mwm. File .vnc/xstartup contains: #!/bin/sh # Uncomment the following two lines for normal desktop: #unset SESSION_MANAGER #exec /etc/X11/xinit/xinitrc xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & mwm & #using the motif window manager # You should also copy the mwm config file: cd; cp /etc/X11/system.mwmrc .mwmrc; chmod 644 .mwmrc If you are reading this, then VNC is not working and you have no access to a GUI. There are two solutions: (a) copy my xstartup and make it executable: cd ; cp ~paknys/xstartup ./.vnc ; chmod 755 ./.vnc/xstartup or (b) logged in with Putty, type it in using an editor such as pico that does not require a GUI. cd pico .vnc/xstartup Type the file, save it, exit the editor chmod 755 .vnc/xstartup ******************************************** **** Make it Automatic ********************* ******************************************** You can simplify your life by using scripts. On my machine I keep them in /usr/local/bin and are shown below. You are free to copy them. I do not offer any guarantees or addtional help for this topic. vncstart ;start the server vncstop ;stop it vncclean ;clean up files, if it crashed Typing the command with no arguments prints out help. ****/usr/local/bin> cat vncstart #!/bin/tcsh # RP March 9, 2012 # For port 5902, usage: vncstart 2 if($#argv == 0) then echo 'Usage:' echo 'vncstart 2 4x3 =>port 5902, size 4x3 on 1280x1024' echo 'vncstart 2 =>port 5902, with default 4x3' echo 'The size options are: 4x3 or 16x9 or lowres' echo '------ Server not started. ------' endif # if($#argv == 1) then echo 'Assuming 4x3 on 1280x1024' vncserver :$1 -geometry 1270x950 -depth 16 endif # if($#argv == 2) then if($2 == "4x3")then echo 'Assuming 4x3 on 1280x1024' vncserver :$1 -geometry 1270x950 -depth 16 endif if($2 == "16x9")then echo 'Assuming 16x9 on 1680x1050' vncserver :$1 -geometry 1670x970 -depth 16 endif if($2 == "lowres")then echo 'Assuming low resolution 4x3 on 1024x768' #classroom 4x3 vncserver :$1 -geometry 1000x700 -depth 16 endif endif # if($#argv >0) then cat $HOME/.vnc/$HOSTNAME\:$1.log | grep -s Listening\ for\ VNC endif # **** /usr/local/bin>cat vncstop #!/bin/tcsh # RP March 9, 2012 if($#argv == 0) then echo 'Usage:' echo 'vncstop 2 =>Stop the VNC server on port 5902' echo '------ Nothing done. ------' endif if($#argv == 1) then vncserver -kill :$1 endif # **** /usr/local/bin>cat vncclean #!/bin/tcsh # RP March 9, 2012, rev. March 9, 2013. # Usage vncclean 2 if($#argv == 0) then echo 'Usage:' echo 'vncclean 2 =>remove bad files from server crash, for port 5902' echo '------ Nothing done. ------' endif # if($#argv == 1) then echo 'Removing: /tmp/.X*-lock and /tmp/.X11-unix/X*' /bin/rm -f /tmp/.X$1-lock; /bin/rm -f /tmp/.X11-unix/X$1 echo 'Removing: '.vnc/ .pid file' /bin/rm -f $HOME/.vnc/$HOSTNAME\:$1.pid echo 'If present, kill bonobo, gam_server, gnome-panel, gconfd ' pkill -9 -u $USER bonobo-activation-server pkill -9 -u $USER gam_server pkill -9 -u $USER gnome-panel pkill -9 -u $USER gconfd endif # Last update May 14, 2020 by R. Paknys