Difference between revisions of "VNC"

From PHASTA Wiki
Jump to: navigation, search
Line 1: Line 1:
 
VNC is a tool which projects a GUI session over the network. If may be useful if you want to use GUI tools remotely when X forwarding performs poorly.  
 
VNC is a tool which projects a GUI session over the network. If may be useful if you want to use GUI tools remotely when X forwarding performs poorly.  
  
'''Warning: This is still being tested and should NOT be considered stable (portal0 may be rebooted without warning)'''
 
 
'''Warning: The vnc password is transmitted in clear text over the network and should not be considered secure'''
 
'''Warning: The vnc password is transmitted in clear text over the network and should not be considered secure'''
  
Portal0 is designated to host VNC sessions.
+
Portal1 is designated to host VNC sessions.
  
  
Line 10: Line 9:
  
 
   ssh jumpgate-phasta.colorado.edu
 
   ssh jumpgate-phasta.colorado.edu
   ssh portal0
+
   ssh portal1
 
   source /etc/profile
 
   source /etc/profile
 
   start_vnc.sh
 
   start_vnc.sh
Line 16: Line 15:
 
Then follow the directions from start_vnc.sh. Make sure to remember your password and port number (59**) so that you can reuse your session.
 
Then follow the directions from start_vnc.sh. Make sure to remember your password and port number (59**) so that you can reuse your session.
  
It's okay to leave your VNC session running on portal0. Next time you want to access your desktop, just ssh into jumpgate with a tunnel between portal0's vnc port (59**) and some port on your machine. Then use a VNC client to connect to the port on your machine.
+
It's okay to leave your VNC session running on portal1. Next time you want to access your desktop, just ssh into jumpgate with a tunnel between portal1's vnc port (59**) and some port on your machine. Then use a VNC client to connect to the port on your machine.
  
 
If, for some reason, you want to end your session and kill your virtual desktop, run
 
If, for some reason, you want to end your session and kill your virtual desktop, run
Line 26: Line 25:
 
== OpenGL ==  
 
== OpenGL ==  
  
Portal0 is equipped with a VirtualGL install which will allow you to use OpenGL programs (which do not use pthreads)
+
Portal1 is 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
 
Simply wrap your OpenGL program with the "vglrun" command
 
   vlgrun glxgears
 
   vlgrun glxgears
  
If you have access to another VirtualGL server you can connect to it first (Portal0 doesn't have a particularly fast graphics processor)
+
If you have access to another VirtualGL server you can connect to it first (Portal1 doesn't have a particularly fast graphics processor)
 
   vglconnect server
 
   vglconnect server
 
   vglrun glxgears
 
   vglrun glxgears
Line 40: Line 39:
 
== Clients ==  
 
== Clients ==  
  
Portal0 uses TurboVNC from the VirtualGL project, available from http://www.virtualgl.org/Downloads/TurboVNC
+
Portal1 uses TurboVNC from the VirtualGL project, available from http://www.virtualgl.org/Downloads/TurboVNC
  
 
Other VNC viewers will also work, such as TightVNC and RealVNC
 
Other VNC viewers will also work, such as TightVNC and RealVNC
Line 60: Line 59:
 
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/
 
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/
  
When you open putty, enter jumpgate-phasta.colorado.edu as 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 run "ssh -L????:portal0:???? jumpgate-phasta.colorado.edu" on your machine. Enter the number between the -L and the first colon in the "Source port" box. Enter the rest in the Destination box (starting with portal0) and '''click the add button'''. Then click "Open" and login as normal. You will then be able to use a vncviewer as instructed by the script.
+
When you open putty, enter jumpgate-phasta.colorado.edu as 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 run "ssh -L????:portal1:???? jumpgate-phasta.colorado.edu" on your machine. Enter the number between the -L and the first colon in the "Source port" box. Enter the rest in the Destination box (starting with portal1) and '''click the add button'''. Then click "Open" and login as normal. You will then be able to use a vncviewer as instructed by the script.
  
 
Example:
 
Example:
  
 
The script says:
 
The script says:
ssh -L5905:portal0:5900 jumpgate-phasta.colorado.edu
+
ssh -L5905:portal1:5900 jumpgate-phasta.colorado.edu
 
enter 5905 in the Source port box
 
enter 5905 in the Source port box
enter portal0:5900 in the destination box.
+
enter portal1:5900 in the destination box.
  
 
Try using this viewer utility
 
Try using this viewer utility
Line 74: Line 73:
 
'''Connecting to your VNC with PuTTY'''
 
'''Connecting to your VNC with PuTTY'''
  
Once we SSH to jumpgate (on the default SSH port 22), our main desktop on portal0 can be accessed via a VNC session as follows.
+
Once we SSH to jumpgate (on the default SSH port 22), our main desktop on portal1 can be accessed via a VNC session as follows.
  
# The VNC server should already be running on portal0 using port 59xx.
+
# The VNC server should already be running on portal1 using port 59xx.
## To check the port, on portal0 run <code>/opt/vnc_script/findsession.sh</code>
+
## To check the port, on portal1 run <code>/opt/vnc_script/findsession.sh</code>
 
## To confirm the VNC server is running (and see port), run <code>ps aux | grep vnc</code>
 
## To confirm the VNC server is running (and see port), run <code>ps aux | grep vnc</code>
 
# Open PuTTY on your local machine.
 
# Open PuTTY on your local machine.
 
# Under "Session", SSH to <code>x@jumpgate-phasta.colorado.edu:22</code>, where <code>x</code> is your username on jumpgate, and <code>22</code> is the standard SSH port.
 
# Under "Session", SSH to <code>x@jumpgate-phasta.colorado.edu:22</code>, where <code>x</code> is your username on jumpgate, and <code>22</code> is the standard SSH port.
# Under "Session">"SSH">"Tunnels", select source port <code>59xx</code> and destination port <code>portal0:59xx</code>, where <code>xx</code> is the two-digit number of your VNC session. Select destination <code>local</code> and click "Add". We select <code>local</code> because we have a service (VNC Server) running on a machine (portal0) that can be reached from the remote machine (jumpgate), and we want to access it directly from the <code>local</code> machine.
+
# Under "Session">"SSH">"Tunnels", select source port <code>59xx</code> and destination port <code>portal1:59xx</code>, where <code>xx</code> is the two-digit number of your VNC session. Select destination <code>local</code> and click "Add". We select <code>local</code> because we have a service (VNC Server) running on a machine (portal1) that can be reached from the remote machine (jumpgate), and we want to access it directly from the <code>local</code> machine.
# Confirm the dialog by clicking "Open", thus establishing an SSH connection between localhost and jumpgate, and tunneling localhost:59xx to portal0:59xx via this connection.
+
# Confirm the dialog by clicking "Open", thus establishing an SSH connection between localhost and jumpgate, and tunneling localhost:59xx to portal1:59xx via this connection.
 
# Open RealVNC, and connect to <code>localhost:xx</code>, which is shorthand for <code>localhost:59xx</code>. VNC ports are enumerated starting with <code>5901</code>, so any two digit port <code>xx</code> is assumed to be port <code>59xx</code>.
 
# Open RealVNC, and connect to <code>localhost:xx</code>, which is shorthand for <code>localhost:59xx</code>. VNC ports are enumerated starting with <code>5901</code>, so any two digit port <code>xx</code> is assumed to be port <code>59xx</code>.
# You should now have access to your desktop on portal0.
+
# You should now have access to your desktop on portal1.
  
 
== Web Based Viewer ==
 
== Web Based Viewer ==
Line 92: Line 91:
 
Forward your session through jumpgate as before before, adding a second port, 580n. For example, if the script tells you to  
 
Forward your session through jumpgate as before before, adding a second port, 580n. For example, if the script tells you to  
  
ssh -L5905:portal0:5902 jumpgate-phasta.colorado.edu you should
+
ssh -L5905:portal1:5902 jumpgate-phasta.colorado.edu you should
   ssh -L5902:portal0:5902 -L5802:portal0:5802 jumpgate-phasta.colorado.edu
+
   ssh -L5902:portal1:5902 -L5802:portal1:5802 jumpgate-phasta.colorado.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)
 
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)
  
Line 111: Line 110:
  
 
== Finding an Existing Session ==
 
== Finding an Existing Session ==
SSH to portal0 and then run:
+
SSH to portal1 and then run:
 
   /opt/vnc_script/findsession.sh
 
   /opt/vnc_script/findsession.sh
  

Revision as of 16:09, 19 May 2017

VNC is a tool which projects a GUI session over the network. If may be useful if you want to use GUI tools remotely when X forwarding performs poorly.

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

Portal1 is designated to host VNC sessions.


To start a VNC session:

 ssh jumpgate-phasta.colorado.edu
 ssh portal1
 source /etc/profile
 start_vnc.sh

Then follow the directions from start_vnc.sh. Make sure to remember your password and port number (59**) so that you can reuse your session.

It's okay to leave your VNC session running on portal1. Next time you want to access your desktop, just ssh into jumpgate with a tunnel between portal1's vnc port (59**) and some port on your machine. Then use a VNC client to connect to the port on your machine.

If, for some reason, you want to end your session and kill your virtual desktop, run

 source /etc/profile
 stop_vnc.sh     # ONLY run this if you want to kill your virtual desktop.


OpenGL

Portal1 is 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

 vlgrun glxgears

If you have access to another VirtualGL server you can connect to it first (Portal1 doesn't have a particularly fast graphics processor)

 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)

Clients

Portal1 uses TurboVNC from the VirtualGL project, available from http://www.virtualgl.org/Downloads/TurboVNC

Other VNC viewers will also work, such as TightVNC and RealVNC

Changing the VNC Password

 /opt/tigervnc/bin/vncpasswd

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

Windows

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/

When you open putty, enter jumpgate-phasta.colorado.edu as 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 run "ssh -L????:portal1:???? jumpgate-phasta.colorado.edu" on your machine. Enter the number between the -L and the first colon in the "Source port" box. Enter the rest in the Destination box (starting with portal1) and click the add button. Then click "Open" and login as normal. You will then be able to use a vncviewer as instructed by the script.

Example:

The script says: ssh -L5905:portal1:5900 jumpgate-phasta.colorado.edu enter 5905 in the Source port box enter portal1:5900 in the destination box.

Try using this viewer utility http://www.tightvnc.com/download/1.3.10/tightvnc-1.3.10_x86_viewer.zip

Connecting to your VNC with PuTTY

Once we SSH to jumpgate (on the default SSH port 22), our main desktop on portal1 can be accessed via a VNC session as follows.

  1. The VNC server should already be running on portal1 using port 59xx.
    1. To check the port, on portal1 run /opt/vnc_script/findsession.sh
    2. To confirm the VNC server is running (and see port), run ps aux | grep vnc
  2. Open PuTTY on your local machine.
  3. Under "Session", SSH to x@jumpgate-phasta.colorado.edu:22, where x is your username on jumpgate, and 22 is the standard SSH port.
  4. Under "Session">"SSH">"Tunnels", select source port 59xx and destination port portal1:59xx, where xx is the two-digit number of your VNC session. Select destination local and click "Add". We select local because we have a service (VNC Server) running on a machine (portal1) that can be reached from the remote machine (jumpgate), and we want to access it directly from the local machine.
  5. Confirm the dialog by clicking "Open", thus establishing an SSH connection between localhost and jumpgate, and tunneling localhost:59xx to portal1:59xx via this connection.
  6. Open RealVNC, and connect to localhost:xx, which is shorthand for localhost:59xx. VNC ports are enumerated starting with 5901, so any two digit port xx is assumed to be port 59xx.
  7. You should now have access to your desktop on portal1.

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 before, adding a second port, 580n. For example, if the script tells you to

ssh -L5905:portal1:5902 jumpgate-phasta.colorado.edu you should

 ssh -L5902:portal1:5902 -L5802:portal1:5802 jumpgate-phasta.colorado.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)

Changing the Size (Resolution) of an Existing Session

You can usually use the "xrandr" tool to change the resolution of a running vnc session. First you'll need to know your session's display number (this should be the last digit or two of the port number). For example, if your VNC session is running on port 5902, then your screen number should be :2. For this example, we'll use screen 2.

Once you know your screen number, you can see the list of supported modes as follows:

 xrandr -display :2

Once you pick the one you want (generally the same size or smaller than the native resolution of your client), you can choose it by running a command like

 xrandr -s 1400x1050 -display :2

(this example will set the resolution to 1400 pixels by 1050 pixels)

You'll probably be disconnected at this point, but when you reconnect your screen size should be changed (hopefully without crashing your running programs).

Finding an Existing Session

SSH to portal1 and then run:

 /opt/vnc_script/findsession.sh

Which will return the shortened port number of each of your currently running sessions.

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

stop_vnc.sh may display some errors; this is normal.

If you have trouble deleting ~/.vnc send an email to Benjamin.A.Matthews@colorado.edu

If any of these commands fail, you may need to source /etc/profile to get the necessary environment variables (this should be fixed soon)

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 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 Benjamin.A.Matthews@Colorado.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 you're running OSX and see an error about Zlib, try changing your compression settings (maximum quality usually works) or use a different client. RealVNC and certain versions of ChickenOfTheVNC both exhibit this issue. The latest build of TigerVNC should work reliably, as does the Java based TightVNC client.