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.
- A VPS running any of our available OS options.
- A non-root user account (commands requiring escalated privileges will use
- 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.
What’s the BEST DEAL in cloud hosting?
Develop at hyperspeed with a Performance VPS from SSD Nodes. We just DOUBLED the amount of blazing-fast NVMe storage and beefed up the CPU offering on these plans. There’s nothing else like it on the market, at least not at these prices.
Score a 16GB Performance VPS with 160GB of NVMe storage for just $109/year for a limited time!
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
sudo apt install xauth # Debian/Ubuntu sudo yum install xorg-x11-xauth # CentOS
/etc/ssh/sshd_config with your favorite editor and look for the
X11Forwarding option. This line should be uncommented and be changed to
After that, you should restart
sudo systemctl restart sshd
You should then disconnect from your VPS and reconnect. At this point, check to make sure that X11 forwarding is indeed enabled. You should see the following output if it’s working correctly:
echo $DISPLAY localhost:10.0
Let’s install something simple to test out—how about
xclock? Once it’s installed, you can run it from the VPS and it will appear on your local machine’s desktop.
sudo apt install x11-apps # Debian/Ubuntu sudo yum install x11-apps # CentOS xclock
Now you can run just about any X application, from
firefox. Could be particularly useful if you need to install something on your VPS that only has a graphical installer.
Forwarding an entire remote Linux desktop
Running single X applications might be useful every now and then, but what about a full remote Linux desktop? That could go a long way if you need to use GUI applications on your VPS regularly.
For this tutorial, we’ll quickly install the XFCE desktop environment—a good, low-resource choice for this kind of usage—and then forward it via SSH.
sudo touch /dev/fuse sudo apt install xfce4 xfce4-goodies gnome-icon-theme
sudo yum install epel-release -y sudo yum groupinstall "X Window system" sudo yum groupinstall xfce
Once XFCE is installed, you can SSH into your VPS (if you’re not already) and begin a new session:
The remote desktop will appear directly on your own.
|A remote XFCE session running (somewhat ungracefully) on my Fedora/Gnome-based local machine via X11 forwarding|
Remote Linux desktops via VNC
VNC is yet another option for those who want to connect to a remote machine and use the full desktop. It’s a little more involved that some of the others, but we’ll walk through the quickest way to get a VNC server up and running.
Before you go ahead with VNC, you should follow the instructions above on installing XFCE or another desktop environment.
First, you need to install a VNC server on your VPS.
sudo apt-get install tightvncserver # Debian/Ubuntu sudo yum install tigervnc-server # CentOS
Then you can run the server itself. The first time, you’ll be prompted to create a VNC-only password.
vncserver :1 -geometry 800x600 -depth 24 You will require a password to access your desktops. Password: Verify: xauth: file /home/user/.Xauthority does not exist New 'user:1 (user)' desktop is hostname:1 Creating default startup script /home/user/.vnc/xstartup Starting applications specified in /home/user/.vnc/xstartup Log file is /home/user/.vnc/hostname:1.log
Finally, start up your favorite VNC client. A number of options exist depending on your operating system:
- Vinagre [Linux]
- Real VNC [Windows/OS X/Linux/iOS/Android]
- TightVNC [Windows/OS X/Linux]
- TigerVNC [Linux/Windows/OS X]
Connect to your VNC server by appending
:1 to the IP address of your VPS. You’ll have access to the full desktop!
Note: The default VNC server isn’t very secure, and creates another potential attack vector. Be sure to check out the resources below for more information about securing your VNC server.
- How to secure VNC with SSH
- VNC Server Security
- X inside VE
- X11 forwarding and SSH for remote linux / ubuntu desktop
[cta text=”Run a remote desktop for $1.11/mo and get 16GB RAM.” text2=”You’re 90 seconds away from running a remote desktop on SSD Nodes!” button=”Deploy a remote desktop”]