{"id":90,"date":"2017-05-15T00:00:00","date_gmt":"2017-05-15T00:00:00","guid":{"rendered":"http:\/\/ssdnodes.billabailey.com\/2017\/05\/15\/tutorial-accessing-a-linux-desktop-remotely-with-ssh-and-vnc\/"},"modified":"2025-07-16T14:40:45","modified_gmt":"2025-07-16T14:40:45","slug":"remote-linux-desktop-vps-ssh-vnc","status":"publish","type":"post","link":"https:\/\/www.ssdnodes.com\/blog\/remote-linux-desktop-vps-ssh-vnc\/","title":{"rendered":"Remote Linux desktop on your VPS with SSH and VNC"},"content":{"rendered":"<p>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.<\/p>\n<p>There are a number of ways to get this done, from running single commands via X11 forwarding and <code>ssh<\/code>, to forwarding an entire desktop, to using VNC. In this tutorial, we\u2019ll cover how to do each of these so that you can choose the application that works best for your needs.<\/p>\n<p><em>Note: We can\u2019t guarantee these operations will be particularly fast\u2014primarily due to latency between your machine and your VPS\u2014but it could come in handy every once in awhile.<\/em><\/p>\n<h2><a id=\"Prerequisites_8\"><\/a>Prerequisites<\/h2>\n<ul>\n<li>A VPS running any of our available OS options.<\/li>\n<li>A non-root user account (commands requiring escalated privileges will use <code>sudo<\/code>).<\/li>\n<li>A local machine running Linux, an OS X machine with XQuartz installed, or a Windows machine with Xming installed\u2014this tutorial depends on having some type of X server running locally.\n<ul>\n<li>Windows users should install <a href=\"http:\/\/www.straightrunning.com\/XmingNotes\/\" target=\"_blank\" rel=\"noopener\">Xming<\/a>.<\/li>\n<li>OS X users should install <a href=\"https:\/\/www.xquartz.org\/\" target=\"_blank\" rel=\"noopener\">XQuartz<\/a>.<\/li>\n<li>Once Xming\/XQuartz are installed, you can then launch an <code>xterm<\/code> or other terminal to ssh into your VPS and enable X11 tunneling.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div class=\"cta-inline\"><\/div>\n<h2><a id=\"Forwarding_single_X_applications_18\"><\/a>Forwarding single X applications<\/h2>\n<p>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 <code>ssh<\/code> using the <code>-X<\/code> option, which enables X forwarding, and the <code>-C<\/code> option, which enables data compression.<\/p>\n<pre><code class=\"language-shell hljs\"><span class=\"hljs-meta\">$<\/span><span class=\"bash\"> ssh -XC user@IP-ADDRESS<\/span>\n<\/code><\/pre>\n<p>Once into the VPS, you should first install the <code>xauth<\/code> package.<\/p>\n<pre><code class=\"language-shell hljs\"><span class=\"hljs-meta\">$<\/span><span class=\"bash\"> sudo apt install xauth             <span class=\"hljs-comment\"># Debian\/Ubuntu<\/span><\/span>\n<span class=\"hljs-meta\">$<\/span><span class=\"bash\"> sudo yum install xorg-x11-xauth    <span class=\"hljs-comment\"># CentOS<\/span><\/span>\n<\/code><\/pre>\n<p>Then, open <code>\/etc\/ssh\/sshd_config<\/code> with your favorite editor and look for the <code>X11Forwarding<\/code> option. This line should be uncommented and be changed to <code>X11Forwarding yes<\/code>.<\/p>\n<p>After that, you should restart <code>sshd<\/code>.<\/p>\n<pre><code class=\"language-shell hljs\"><span class=\"hljs-meta\">$<\/span><span class=\"bash\"> sudo systemctl restart sshd<\/span>\n<\/code><\/pre>\n<p>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\u2019s working correctly:<\/p>\n<pre><code class=\"language-shell hljs\"><span class=\"hljs-meta\">$<\/span><span class=\"bash\"> <span class=\"hljs-built_in\">echo<\/span> <span class=\"hljs-variable\">$DISPLAY<\/span><\/span>\nlocalhost:10.0\n<\/code><\/pre>\n<p>Let\u2019s install something simple to test out\u2014how about <code>xclock<\/code>? Once it\u2019s installed, you can run it from the VPS and it will appear on your local machine\u2019s desktop.<\/p>\n<pre><code class=\"language-shell hljs\"><span class=\"hljs-meta\">$<\/span><span class=\"bash\"> sudo apt install x11-apps      <span class=\"hljs-comment\"># Debian\/Ubuntu<\/span><\/span>\n<span class=\"hljs-meta\">$<\/span><span class=\"bash\"> sudo yum install x11-apps      <span class=\"hljs-comment\"># CentOS<\/span><\/span>\n<span class=\"hljs-meta\">$<\/span><span class=\"bash\"> xclock<\/span>\n<\/code><\/pre>\n<p>Now you can run just about any X application, from <code>gedit<\/code> to <code>firefox<\/code>. Could be particularly useful if you need to install something on your VPS that only has a graphical installer.<\/p>\n<h2>Forwarding an entire remote Linux desktop<\/h2>\n<p>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.<\/p>\n<p>For this tutorial, we\u2019ll quickly install the XFCE desktop environment\u2014a good, low-resource choice for this kind of usage\u2014and then forward it via SSH.<\/p>\n<p><strong>Debian\/Ubuntu<\/strong><\/p>\n<pre><code class=\"language-shell hljs\"><span class=\"hljs-meta\">$<\/span><span class=\"bash\"> sudo touch \/dev\/fuse<\/span>\n<span class=\"hljs-meta\">$<\/span><span class=\"bash\"> sudo apt install xfce4 xfce4-goodies gnome-icon-theme<\/span>\n<\/code><\/pre>\n<p><strong>CentOS<\/strong><\/p>\n<pre><code class=\"language-shell hljs\"><span class=\"hljs-meta\">$<\/span><span class=\"bash\"> sudo yum install epel-release -y<\/span>\n<span class=\"hljs-meta\">$<\/span><span class=\"bash\"> sudo yum groupinstall <span class=\"hljs-string\">\"X Window system\"<\/span><\/span>\n<span class=\"hljs-meta\">$<\/span><span class=\"bash\"> sudo yum groupinstall xfce<\/span>\n<\/code><\/pre>\n<p>Once XFCE is installed, you can SSH into your VPS (if you\u2019re not already) and begin a new session:<\/p>\n<pre><code class=\"hljs shell\"><span class=\"hljs-meta\">$<\/span><span class=\"bash\"> xfce4-session<\/span>\n<\/code><\/pre>\n<p>The remote desktop will appear directly on your own.<\/p>\n<table class=\"table table-striped table-bordered\">\n<thead>\n<tr>\n<th><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><em>A remote XFCE session running (somewhat ungracefully) on my Fedora\/Gnome-based local machine via X11 forwarding<\/em><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Remote Linux desktops via VNC<\/h2>\n<p>VNC is yet another option for those who want to connect to a remote machine and use the full desktop. It\u2019s a little more involved that some of the others, but we\u2019ll walk through the quickest way to get a VNC server up and running.<\/p>\n<p>Before you go ahead with VNC, you should follow the instructions above on installing XFCE or another desktop environment.<\/p>\n<p>First, you need to install a VNC server on your VPS.<\/p>\n<pre><code class=\"language-shell hljs\"><span class=\"hljs-meta\">$<\/span><span class=\"bash\"> sudo apt-get install tightvncserver   <span class=\"hljs-comment\"># Debian\/Ubuntu<\/span><\/span>\n<span class=\"hljs-meta\">$<\/span><span class=\"bash\"> sudo yum install tigervnc-server      <span class=\"hljs-comment\"># CentOS<\/span><\/span>\n<\/code><\/pre>\n<p>Then you can run the server itself. The first time, you\u2019ll be prompted to create a VNC-only password.<\/p>\n<pre><code class=\"language-shell hljs\"><span class=\"hljs-meta\">$<\/span><span class=\"bash\"> vncserver :1 -geometry 800x600 -depth 24<\/span>\n\nYou will require a password to access your desktops.\n\nPassword:\nVerify:\nxauth:  file \/home\/user\/.Xauthority does not exist\n\nNew 'user:1 (user)' desktop is hostname:1\n\nCreating default startup script \/home\/user\/.vnc\/xstartup\nStarting applications specified in \/home\/user\/.vnc\/xstartup\nLog file is \/home\/user\/.vnc\/hostname:1.log\n<\/code><\/pre>\n<p>Finally, start up your favorite VNC client. A number of options exist depending on your operating system:<\/p>\n<ul>\n<li><a href=\"https:\/\/help.ubuntu.com\/community\/Vinagre\" target=\"_blank\" rel=\"noopener\">Vinagre<\/a> [Linux]<\/li>\n<li><a href=\"https:\/\/www.realvnc.com\/download\/viewer\/\" target=\"_blank\" rel=\"noopener\">Real VNC<\/a> [Windows\/OS X\/Linux\/iOS\/Android]<\/li>\n<li><a href=\"http:\/\/www.tightvnc.com\/download.php\" target=\"_blank\" rel=\"noopener\">TightVNC<\/a> [Windows\/OS X\/Linux]<\/li>\n<li><a href=\"http:\/\/tigervnc.org\/\" target=\"_blank\" rel=\"noopener\">TigerVNC<\/a> [Linux\/Windows\/OS X]<\/li>\n<\/ul>\n<p>Connect to your VNC server by appending <code>:1<\/code> to the IP address of your VPS. You\u2019ll have access to the full desktop!<\/p>\n<p><em>Note:<\/em> The default VNC server isn\u2019t very secure, and creates another potential attack vector. Be sure to check out the resources below for more information about securing your VNC server.<\/p>\n<h2><a id=\"Further_resources_131\"><\/a>Further resources<\/h2>\n<ul>\n<li><a href=\"http:\/\/www.mit.edu\/~avp\/lqcd\/ssh-vnc.html\" target=\"_blank\" rel=\"noopener\">How to secure VNC with SSH<\/a><\/li>\n<li><a href=\"https:\/\/askubuntu.com\/questions\/476583\/vnc-server-security\" target=\"_blank\" rel=\"noopener\">VNC Server Security<\/a><\/li>\n<li><a href=\"https:\/\/openvz.org\/X_inside_VE\" target=\"_blank\" rel=\"noopener\">X inside VE<\/a><\/li>\n<li><a href=\"http:\/\/www.craigryder.com\/linux-ubuntudebetc\/x11-forwarding-and-ssh-for-remote-linux-ubuntu-desktop\/\" target=\"_blank\" rel=\"noopener\">X11 forwarding and SSH for remote linux \/ ubuntu desktop<\/a><\/li>\n<\/ul>\n<p>[cta text=&quot;Run a remote desktop for $1.11\/mo and get 16GB RAM.&quot; text2=&quot;You're 90 seconds away from running a remote desktop on SSD Nodes!&quot; button=&quot;Deploy a remote desktop&quot;]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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.<\/p>\n","protected":false},"author":20,"featured_media":2131,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[18,30],"tags":[],"class_list":["post-90","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","category-tutorials"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts\/90","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/comments?post=90"}],"version-history":[{"count":3,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts\/90\/revisions"}],"predecessor-version":[{"id":13496,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts\/90\/revisions\/13496"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/media\/2131"}],"wp:attachment":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/media?parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/categories?post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/tags?post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}