VNC

From ScorecWiki

Jump to: navigation, search

Contents

Overview

VNC is a tool which projects a desktop session over the network. If may be useful if you want to use GUI tools remotely when X forwarding performs poorly. The popular use of VNC is to access a computer from work or by using another computer. By connecting a VNC viewer to a VNC server, a remote desktop is created on your local machine. Multiple VNC viewer clients can connect to a VNC server. In this case, users can use VNC to connect to a VNC server in SCOREC from another computer outside the network.

Image:SSH_Tunneling.png

Warning: The vnc password is transmitted in clear text over the SCOREC network and should not be considered secure

Tutorial Video

The following tutorial was created on March 25th, 2020:

https://www.scorec.rpi.edu/~cwsmith/vncTutorial.mp4

Starting the Server

portal2.scorec.rpi.edu is designated to host VNC sessions.

You can start a session by first connecting to jumpgate. Type the following into a command prompt:

 ssh jumpgate.scorec.rpi.edu

Once connected to jumpgate (the command prompt should say USERNAME@jumpgate.scorec.rpi.edu), ssh to Portal2:

 ssh portal2

Once connected, (the command prompt should now say USERNAME@portal*), start the VNC server as follows:

 /opt/vnc_script/start_vnc.sh --geometry <width>x<height>

where <width> and <height> should be replaced by the resolution you would like for your remote desktop. Setting the resolution to match your displays resolution is sensible. So, for example, if my display is 1600x1200 the vncserver command will be:

 /opt/vnc_script/start_vnc.sh --geometry 1600x1200

Your VNC Sever is now started. It is suggested to save the example ssh command provided on the line 'you can use ssh -Ln:localhost:59## on portal2.scorec.rpi.edu' in a textfile for later use.

After the vnc is started reset your password using the following command. Note, that the characters you enter will not be displayed as you type them.

 vncpasswd

When you are done, you can simply close your viewer and resume your session later. Remember, a key benefit to using a VNC server is that it remains running so that you can connect and disconnect as needed to quickly resume your work. If you think you successfully created your VNC server, and are having problems connecting to it, please email help@scorec.rpi.edu or ask for help; it is likely a port forwarding issue.


You should NOT use the Gnome Logout button/menu from within a VNC session.

Connecting to the VNC server using a VNC client

Clients

You can use RealVNC (http://www.realvnc.com/download/viewer/).

Other VNC viewers will also work, such as TightVNC (http://www.tightvnc.com/download/1.3.10/tightvnc-1.3.10_x86_viewer.zip) and TurboVNC from the VirtualGL project (http://www.virtualgl.org/Downloads/TurboVNC)

Download one of the VNC viewers on your local machine (the machine you are currently on).

Connecting from outside

In order to connect to the VNC server from outside the network, the connection needs to be forwarded through a SSH tunnel in order to bypass the firewall (refer to Figure 1 from above). The connection go through jumpgate then is the VNC port for portal (the host).

This can be done using Terminal on a UNIX/Linux system or with PuTTY on a Windows system. On a UNIX system, type the following in Terminal:

 ssh -L####:HOSTNAME:SERVER_PORT_NUMBER USERNAME@jumpgate.scorec.rpi.edu
  • The information for the #### (the LOCAL_PORT_NUMBER), HOSTNAME, and SERVER_PORT_NUMBER are found in the vnc_script.

On a Windows system, follow the instructions below for using PuTTY.

On a UNIX/Linux system

If you are connecting from campus

A UNIX/Linux system has its own VNC viewer via Terminal. Type the following into Terminal to open the VNC viewer:

 vncviewer

It will ask for the VNC server:

 HOSTNAME:SERVER_PORT_NUMBER
  • Using host portal2 and server port number 5555, it would be portal2:5555
  • It will also ask for the password you set with vncpasswd


Alternatively, you can use TightVNC.

Using TightVNC:

 Enter in VNC server box: USERNAME@jumpgate.scorec.rpi.edu:SERVER_PORT_NUMBER

If you are connecting from off campus

A UNIX/Linux system has its own VNC viewer via Terminal. Type the following into Terminal to open the VNC viewer:

 vncviewer

It will ask for the VNC server:

 :LOCAL_PORT_NUMBER
  • It will also ask for the password you set with vncpasswd

On a Windows system

The PuTTY SSH client can handle ssh tunneling on Windows based machines. You can download it here: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

When you open putty, enter jumpgate.scorec.rpi.edu in the Host Name box.

Then click the + button next to SSH on the left pane (to expand the SSH tree node). Choose the Tunnels page.

The start_vnc.sh script should tell you to use "ssh -L####:portal2:#### USERNAME@jumpgate.scorec.rpi.edu" on your client machine." Enter the number between the -L and the first colon in the Source port box.

Enter everything after the first colon (starting with portal2 and ending before the USERNAME@jumpgate.scorec.rpi.edu) in the Destination box and click the Add button.

Example:

  • The script output says: ssh -L5905:portal2:5900 jumpgate.scorec.rpi.edu
  • enter 5905 in the Source port box
  • enter portal2:5900 in the Destination box.

Then click "Open" and login as normal using your SCOREC username and password.

Then you can use the vncviewer from a VNC client (like RealVNC).

Enter into the VNC server box the hostname and port number given from the script output.

  • i.e. The script output will say connect vncviewer to "localhost:5", so enter localhost:5 into the VNC server box.

Troubleshooting

- If the error 'Connection closed unexpectedly' appears, make sure the port is not already "in use." This can be solved by simply logging off and logging back in or by checking that there are not multiple putty sessions active, all trying to forward to the same port.

View Only Mode

To share your desktop with another user in view only mode set a view only password by running

 vncpasswd

Have the other user connect in the same way you would but have them set their viewer to be in view only mode and use your view only password. Typically this is done as follows:

 vncviewer -viewonly

Web Based Viewer

If you can't or don't want to install a VNC viewer you can use a Java based one. You will need a JVM and a Java browser plugin. You will also need the port that the start_vnc script assigned you to be free on your local computer

Forward your session through jumpgate as before, adding a second port, 580n. For example, if the script tells you to use

ssh -L5905:portal2:5902 jumpgate.scorec.rpi.edu you should instead use

 ssh -L5902:portal2:5902 -L5802:portal2:5802 jumpgate.scorec.rpi.edu

Then point your browser to http://localhost:5802 and log in with the password specified by the script when prompted. (Replace 2 with the value specified by the script)

OpenGL

Portal2 and Portal3 are equipped with a VirtualGL install which will allow you to use OpenGL programs (which do not use pthreads)

Simply wrap your OpenGL program with the "vglrun" command

 vglrun glxgears

If you have access to another VirtualGL server you can connect to it first

 vglconnect server
 vglrun glxgears


Note that VGL uses a number of threads. If you have trouble with vglrun crashing with a message about Thread::Start() make sure you haven't set your stack size too large (remove any ulimit -s or ulimit -n calls from your shell start scripts)

Othello and Romulus are known to have a working VirtualGL installs.

Troubleshooting

If you have used vncserver (It doesn't matter which version) on a SCOREC machine before, you will need to clear your vnc settings for the script to work. You can do this by running rm -rf ~/.vnc.

If you have trouble deleting ~/.vnc send an email to help@scorec.rpi.edu .

VirtualGL has trouble with some threaded programs. If your OpenGL program exhibits segmentation faults or other issues, this could be the problem. Check back for the solution later.

If the given password is rejected you can run /opt/vnc_script/stop_vnc.sh and restart to get a new one. Occasionally the random password generator may generate passwords which VNC doesn't like.

If VirtualGL complains about not being able to get a 24bit FB config either vglconnect to another VirtualGL enabled server or complain to help@scorec.rpi.edu

If your VNC connection is very slow, you might want to try changing the compression and encoding options. See your vncviewer's documentation or try this

 vncviewer -encodings tight -quality 6 -compresslevel 6

If you have trouble with text distortion try adding

 -nojpeg

If vncviewer states that too many failed authentication/login attempts have been made you will have to stop your server (using the stop_vnc.sh script) and start a new server.

If you've forgotten your session number, you can run the following script:

 /opt/vnc_script/findsession.sh

To stop your VNC server run the following command:

 /opt/vnc_script/stop_vnc.sh
Personal tools