Home Linux Community Community Blogs Desktops Forwarding X11 Apps through SSH

Forwarding X11 Apps through SSH

This quick post illustrates you how to forward remote X11 applications from another machine (called "server" in my example) to local Linux machine (or XWindow server on Windoze machine).

When you're in an insecure network just avoid to use X11 apps, but if you wish to get something else from remote you can do it with SSH, here's a quick example:

your computer name: "client"
other remote host: "server"

Remote username: "ben"
Application to run: "xterm"


Here's a quick and dirty hack for it, no DISPLAY settings or strange things, just one setup.


First setup remote host to allow X11 Port forwarding:

edit /etc/ssh/sshd_config to enable X11Forwading, change or add a line like this:
X11Forwarding yes
Then to make a test try to:
server ~$ cat /etc/ssh/sshd_config |grep X11Forwarding
X11Forwarding yes
If this is the result you've it enabled, note there's no "#" at the beginning of the line


Then connect to remote machine using ssh:

~$ ssh -X -Y ben@server
Please note -X -Y flags for ssh (port forwarding, see man ssh)


Now start your favorite X11 program (xterm in my example)

server ~$ xterm &
[1] 7448

And you're set ! Easy isn't it ?



Hope it helps

Andrea Benini (Ben )



Subscribe to Comments Feed

Upcoming Linux Foundation Courses

  1. LFD312 Developing Applications For Linux
    05 Jan » 09 Jan - Virtual
  2. LFS220 Linux System Administration
    05 Jan » 08 Jan - Virtual
  3. LFD331 Developing Linux Device Drivers
    12 Jan » 16 Jan - Virtual

View All Upcoming Courses

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board