Forwarding X11 Apps through SSH

2629

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 )