This blog is about the Linux Command Line Interface (CLI), with an occasional foray into GUI territory.
Instead of just giving you information like some man page, I hope to illustrate each command in real-life scenarios.

Search This Blog

Monday, May 20, 2013

In the modern networked environment, we often wish to run an application on a remote host while we are comfortably
logged in on our local computer.

Assuming both machines are Linux-based, and the application runs on the graphical X desktop, the following approaches come to mind:

VNC

X11 forwarding over SSH

This article focuses only on X11 forwarding.
X11 forwarding over SSH enables you to run a remote X app and display it locally, with traffic between the 2 hosts encrypted by SSH.

For X11 forwarding over SSH to work, both the SSH client and SSH server must be properly configured.

X11 forwarding must be enabled on The SSH server side. This is the machine where the application resides.
To enable the feature, make sure the X11 configuration file /etc/ssh/sshd_config on the server contains this line:

X11Forwarding yes

If you edit the said file, you need to restart the sshd daemon for the change to take effect.

On the ssh client side, you need to run SSH command with the proper parameters. For instance,
suppose you want to run the xclock application on the remote SSH server and have it displayed back on the local client.

$ ssh peter@192.168.1.112 screen
peter@192.168.1.112's password:
Must be connected to a terminal.

Here is a high-level explanation of what is happening behind the scene.

When you run ssh without a command just to login,
a pseudo tty is automatically allocated. But if you specify a command to execute on the ssh command line, by default, ssh does not allocate a pseudo tty.
You need to force it to allocate one if you want to run commands such as top or screen.
This you do by giving the -t parameter to ssh.