run opengl application over ssh

2 minute read

Run OpenGL application over ssh


OpenGL application can not run through X11 forwarding feature of ssh. For example, when run an opengl application realsense-viewer through ssh using -X option, we’ll face the following error:

# Log in
$ ssh -X jil@

# Run realsense-viewer
$ realsense-viewer 
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
OpenGL 3.0 or ARB_vertex_array_object extension required!

How to run opengl application through ssh

Quick answer

Use VirtualGL and TurboVNC

Long answer

The’re two approach to run opengl application through ssh : Indirect rendering and Server-Side 3D rendering

virtualGL explained these 2 approaches very well. Please go there if you need more information about these topics.

In short-word, Indirect rendering mean the 3d rendering will be occured on local machine while receiving command from server.

Indirect OpenGL Rendering Using GLX FIGURE 1: Indirect OpenGL Rendering Using GLX

I try some below tutorials but still unable to make it work.

  1. opengl-hardware-acceleration-through-remote-x11-ssh-connection
  2. X Window Systemを使ってリモートサーバでOpenGLなプログラムを走らせる方法
  3. how-to-install-opengl-in-ubuntu-linux.aspx

Server-Side 3D rendering mean the 3d will be rendered on server machine. Laterly only the result image is “screen captured” and foward to local machine. Up to now we have : Out-of-Process (X Proxy), In-process (GLX Interposing). VirtualGL is the software that allow us to do the Server-Side 3D rendering. The architecture is as follow:

aaa FIGURE 6: The VGL Transport: In-Process GLX Forking and Image Encoding

Configuration detail

  • We have 2 following machines
  1. Server : ubuntu 16.04、Use to run opengl applications and 3d rendering
  2. Client : ubuntu 18.04、Personal PC
  • For each machine, the following software are added
Machine Software Link
Server virtualgl_2.6.2_amd64.deb sourceforge
Server turbovnc_2.2.3_amd64.deb sourceforge
Client turbovnc_2.2.3_amd64.deb sourceforge

Configure server machine

  • Configure VirtualGL
# log as root
service lightdm stop
# See link for how to answer question
# For maximum sevurity answer recommended answers
  • Create file /etc/systemd/system/turbovncserver@.service on server machine, which has content as follow:
Description=Remote desktop service (VNC)

ExecStartPre=-/opt/TurboVNC/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/opt/TurboVNC/bin/vncserver -geometry 1280x800 :%i
ExecStop=/opt/TurboVNC/bin/vncserver -kill :%i


Note: Please be notify that, i already use the display :1 (port 5901) for normal vnc server. So i use display :2 for turbovnc

  • Edit file ~/.vnc/xstartup.turbovnc on server machine and add the following line to the end of file. Please check that xfce desktop was installed
xfce4-session &
  • Enable turbovncserver service to be run on :2 display
systemctl enable turbovncserver@2.service
  • Reboot
sudo reboot

Configure server machine

No need further configuration

How to use

From client Machinerun vncclient:


Select address as {IP_ADDRESS}:{DISPLAY_NUM} (


Note: for convinient, the password was set be as same as user password

After login, we have the following :


From client Machine, open another terminal. Then use the following commands to run opengl applications.

# ssh -X {IP_ADDRESS}
ssh -X
export DISPLAY=:2
# run opengl application
# or



  1. virtualgl’s background
  5. Setup VirtualGL and TurboVNC on Ubuntu for OpenGL forwarding


Leave a comment