Remote Linux desktop on your VPS with SSH and VNC

Remote Linux desktop on your VPS with SSH and VNC
While you usually connect to your VPS via a terminal, you can also connect to a remote Linux desktop via SSH or VNC to run desktop GUI apps. There are a number of ways to get this done, from running single commands via X11 forwarding and ssh, to forwarding an entire desktop, to using VNC. In this tutorial, we’ll cover how to do each of these so that you can choose the application that works best for your needs. Note: We can’t guarantee these operations will be particularly fast—primarily due to latency between your machine and your VPS—but it could come in handy every once in awhile.

Prerequisites

  • A VPS running any of our available OS options.
  • A non-root user account (commands requiring escalated privileges will use sudo).
  • A local machine running Linux, an OS X machine with XQuartz installed, or a Windows machine with Xming installed—this tutorial depends on having some type of X server running locally.
    • Windows users should install Xming.
    • OS X users should install XQuartz.
    • Once Xming/XQuartz are installed, you can then launch an xterm or other terminal to ssh into your VPS and enable X11 tunneling.
[cta_inline]

Forwarding single X applications

To forward a remote Linux desktop running on your VPS, which allows you to view X applications on your local machine, you should connect via ssh using the -X option, which enables X forwarding, and the -C option, which enables data compression.
$ ssh -XC [email protected]
Once into the VPS, you should first install the xauth package.
$ sudo apt install xauth             # Debian/Ubuntu
$ sudo yum install xorg-x11-xauth    # CentOS
Then, open /etc/ssh/sshd_config with your favorite editor and look for the X11Forwarding option. This line should be uncommented and be changed to X11Forwarding yes. After that, you should restart.... Read More