How to Tunnel X Windows Securely over SSH

Q. How do I tunnel X Windows Securely over SSH? I’d like to run X program on my remote Linux server and get back display to Laptop computer connected by high speed internet?

A. A tunneling protocol is a network protocol which encapsulates a payload protocol, acting as a payload protocol. Reasons to tunnel include carrying a payload over an incompatible delivery network, or to provide a secure path through an untrusted network.

SSH is frequently used to tunnel insecure traffic over the Internet in a secure way. Simply type the following command:

$ ssh -X
$ ssh -X user@

You can requests compression of all data to improve up user experience (good for a low speed link such as wan link) using -c option:
$ ssh -c -X user@

Once logged in type any X windows program name such as:
$ xeys &
$ oowriter &

To start kde type:
$ startkde &

To start default desktop type:
$ startx

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 4 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
4 comments… add one
  • Bruno Nov 21, 2007 @ 14:03

    I can help to say that at least for me, FreeNX from NoMachine has been easy and reliable. I use it a lot from a windows PC and a MacOSX. Configuring a HTTP Proxy is very simple too

  • wekker-tiktak Feb 2, 2008 @ 10:27

    To run qemu to start a virtual machine, on a remote host you need to use the command ssh -Y instead of -X, ssh -X results in an error message without starting an remote virtual machine.

    -Y Enables trusted X11 forwarding. Trusted X11 forwardings are not subjected to the X11 SECURITY extension controls.

    When the sshd server is configured with “X11Forwarding no”, try the following to run remote x xlients:
    1. xhost +localhost
    2. ssh -R 6000: test@ahost
    3. On remote ahost export DISPLAY=

  • frater mus Dec 30, 2011 @ 15:35

    ssh -C = compression
    ssh -c = cipher

  • joon Sep 28, 2014 @ 8:41

    I’m a beginner in linux – please be kind.
    Let me ask a dumb question – in order to tunnel GUI apps over ssh – does the server machine have to have a GUI desktop like gnome installed in order for this to work?

    Or does it just need X installed?

    I wish to establish multiple sessions for different users.


Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum