UsingVNC - MRC CBU Imaging Wiki
CbuImaging: UsingVNC

USING VNC FOR IMAGING





---------------------------

!!WARNING!!

The information on this page is generally useful, but many of the specific details (e.g. host names) are out of date. Please do not follow these instructions literally.


For more upto date information see:

http://intranet.mrc-cbu.cam.ac.uk/computing/cluster-access/

---------------------------









Index


Introduction to VNC

Have you read the warning at the top of the page?

VNC (which stands for Virtual Network Computing) is software designed to make it possible to view and fully interact with one computer from any other.

VNC is probably the best way of connecting to the Linux boxes at the CBU, and thus being able to run SPM. Its main advantage (over Exceed, for instance) is that if you lose your VNC window (for instance due to a computer crash), then all jobs and settings are all still live. This means that SPM processes can continue to run, and the next time you start up your VNC viewer, you will be able to start exactly where you left off, with all SPM and Linux windows as you left them. Another clear advantage is that VNC can easily be adapted so that you can have four sets of desktops running simultaneously in a single VNC viewer.

A) Things you need to do only once:

  • A1) Download Putty (not essential, but very useful). This is freeware and available here. Once downloaded, you should do the following:

    • i) After starting it up, in the “host name” window put in < yourusername@gate.mrc-cbu.cam.ac.uk >. ii) Now in the “saved sessions” section, type in something like <CBU VNC> and press “save”. Now all you have to do to connect to Sabik via SSH is startup Putty and double click on <CBU VNC>. http://imaging.mrc-cbu.cam.ac.uk/images/putty1.jpg

    A2) Now download and install a decent VNC viewer. My favourite is Ultra VNC. A good alternative is Tight VNC.

B) Things you need to do every time you start a new VNC server (should happen very rarely – normally only when the Linux boxes are rebooted):

  • B1) Double click on “CBU VNC” in Putty. Put in your password in the window that opens up, and then connect (via ssh) to one of the Linux boxes. Currently there are around 60 boxes, probably best to select one between L20 and L50. To connect, just type, e.g. <ssh l50>. B2) Now you need to create your VNC server. To do this, type: <vncserver –geometry 1024x768 –name yournamespm> The geometry is the resolution you want the window to be. Any resolutions your monitor doesn't support may cause Matlab to crash, so it's worth choosing a standard resolution. In fact, the best resolution to choose is probably your CURRENT monitor resolution (see below for why). To check the current resolution you are using, right click on the desktop, then go to “properties”, then choose the “settings” tab. The name option can be anything you choose, that you think will usefully label this vncserver. If this if the first ever time you've done this, you may be asked to input a password. B3) A few lines down, you will have something like: “New ‘l50:2 (yournamespm)' desktop is l50:2” The critical thing to note here is the “l50:2” bit, as this is the info you'll need to connect to the server each time. So note this down somewhere.

C) How to connect to your established VNC server from inside the CBU:

  • C1) Now every time you want to connect to this created VNC server, you need to start up your VNC viewer (such as Ultra VNC), and where it asks for a VNC server, you put in the info you just noted down, e.g. <l50:2>. Then press connect, put in your password, and you now are connected.

D) How to connect to your established VNC server from outside the CBU:

  • In addition to running a VNC viewer to connect to the server, you also need to set up a “tunnel” via a (Putty) SSH window.

    D1) (This only needs to be done once for each new VNC server). Start up Putty. Single click on your saved “CBU VNC” session, then click on “load”. On the panel on the left, click on “tunnels” towards the bottom. Where it says “source port” put in <5901> (or the next number up if you are already using this number). Where it says “destination” you need to put in something like <l50:5902>. This is basically the info you noted down above, but adding 5900 to the right-hand-side. Click on “add”. You should now see something like the image below, with a similar line in the “forwarded ports” section. Now on the left panel, click on “Session”, single click on “CBU VNC” again, and click on “save”. This means all your tunnelling parameters are now saved. http://imaging.mrc-cbu.cam.ac.uk/images/putty2.jpg D2) Now, each time you want to start up a VNC session remotely, you need to double click on “CBU VNC” in Putty. Put in your password (you'll need to keep this ssh window open). Then you start your VNC viewer and in the VNC server option, you write: <localhost:1>. Click connect and put in your password.

E) Optimising the display of your VNC Viewer:

  • I’ve found that Ultra VNC is the best choice here, with the smartest options. If you want to abolish the annoying scrollbar at the side, and see the whole of the desktop in one go, then the best choice is to go full screen. This is easiest in Ultra VNC. Either choose this option in the menu (top left button), or type CONTROL+ALT+F12 to flip back and forth between full screen and normal view. I also get rid of the set of buttons to make everything look better. Click on the rightmost toolbar button on the left section at the top to do this. Everything should be very crisp and clear in full screen if your geometry option (see above) matches your current resolution. Instead, you can keep your Start menu in MS Windows visible, but fill the rest of the screen by choosing “auto scale screen” from the menu, though this tends to display text in a rather fuzzy way.

F) Useful commands and tips:

  • F1) To see what VNC servers you are currently running, in any Linux (not Sabik) window, type: <showallvncs>. F2) <showallspms> will do the same for your SPM jobs. F3) To delete a vncserver entirely, in an SSH window (e.g. fired up from Putty), ssh into the Linux box that the VNC server resides, and then type <vncserver –kill :2> where the final number is the final number of the info you noted down above (or that was shown when you typed in <showallvncs>). You should get a confirmation message similar to “Killing Xvnc process ID xxxxx”. F4) In order to create a better virtual environment, with four independent desktops, in any Linux window, type <use_icewm> (if you get a “command not found” error, than type <rehash>; also, note that use_icewm is only available on lower number machines in the cluster using a type of c shell; if you use bash, you can just type tcsh to temporarily change). Confirm you want to change. Note that these changes won't take effect until you start up a new VNC server, so you might want to kill your current one and create a new server. You will then at the bottom see the numbers 1 to 4 that will correspond to four separate desktops (very useful!). If you ever want to change back to the old format, you need to type <use_twm>. F5) You can copy and paste between your VNC viewer and the MS Windows environment if you type <vncconfig>, with various options: < vncconfig &> This is the default and a window will open up with options. <vncconfig -nowin &> The same, but without the window <vncconfig -iconic &> The window will be iconified (usually sitting on the taskbar). If copy/paste stops working for you, try typing vncconfig& on a terminal on the machine you're running vncserver on. For more information, see http://www.realvnc.com/v4/man/vncconfig.html F6) If things go wrong, you might want to check whether the machine you're on can see the appropriate imaging discs. Type <showalldiscs> to see which Linux machines can see which imaging discs. F7) If you ever need to change the VNC password, or have forgotten your current password, you can set a new password from within a Linux xterm window by using the command <vncpasswd>.

G) Connecting externally from a Mac

  • Open Terminal and SSH into gate.mrc-cbu.cam.ac.uk and then a numbered machine to start a vnc session using vncserver, as above.
  • Use SSH to forward a port on your local machine to the remote machine.
    •   ssh -L 5901:l42:5903 username@gate.mrc-cbu.cam.ac.uk -c aes256-cbc
    • <l42> is whatever machine you are running a vnc session on. The forwarding port is determined by the port of your session; the last digit should match the port of your session. In the above example you would connect to <l42:3>. If your session is on <l42:5>, you would use <ssh -L 5901:l42:5905>. The additional switch <-c aes256-cbc> is necessary only for Mac OSX Mountain Lion and after, and is due to the same issue that affects Ubuntu below.

  • Macs have a VNC client built in (confusingly called 'Screen Sharing'). Access it through the Finder menu under Go > Connect and type in e.g. vnc://localhost:5901 as the server. Or use the keyboard shortcut apple-k.

H) VNC on Ubuntu 11.10

On Ubuntu (11.10 anyway) there is a bug in ssh which stops it connecting at all, and tightVNC is almost too slow to be usable. One workaround is as follows:

Use a line like this to make the ssh connection:

  • /usr/bin/ssh  -L 5599:l52:5903 username@gate.mrc-cbu.cam.ac.uk -c aes256-cbc

where l52 is the linux box with your vnc session, 5903 means use display 3, and "-c aes256-cbc" is a magic incantation to get round the bug (see: https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/708493 for the gory details)

then, instead of using vnc, use the "remote desktop viewer" application (from the dashboard). Click "Connect" and enter localhost::5599 as the host

Daniel Bor, Rhodri Cusack, Matt Davis.

CbuImaging: UsingVNC (last edited 2015-09-24 19:30:33 by RussellThompson)