XForwarding With Putty On Windows Over SSH

So I was writing some scripts for my automated web functional testing using PHPUnit and I encountered an error that prevented me from opening the Firefox browser from the server.

When I tried to run my PHPUnit script, I was bothered by this error:

Error: no display specified

I tried running “firefox” on my CentOS CLI and it gave me the same error message. So I found out that my script is trying to run Firefox within the server but the GUI should pop up on the client side.

Apparently, I need to configure some stuff before I’d able to do this.

Problem: I needed to run Firefox from a Linux server remotely and display the GUI locally in my Windows client.

Solution: XForwarding

WHAT’S IN MY MACHINE: Assumptions

  • CentOS Linux
  • PHP 5.4.4
  • Yii 1.1.12

WHAT TO DO: Installations

Your server must have the following installed:

  • Firefox (if not installed, just run this: yum install firefox)
  • X Windows System (if not installed, just run this: yum groupinstall X Window System)

In your client (Windows 7), install the following:

Putty – for the SSH client

Xserver – to display X11 applications

The installation procedure is pretty straightforward so I won’t write it here anymore.

THE TRICKY PART: Configuration

Once you’ve installed the applications, do the following:

1. Double click on the Xming shortcut on your desktop. Your X Server is now running.

2. Click Putty.

3. In Sessions tab, fill in the details:

Host Name (or IP address) – you should put here the IP address of your server
Port – 22
Connection Type: SSH

4. Expand the Connection tab and find and click the SSH branch.

Check the “Enable X11 forwarding”
Check the MIT-Magic-Cookie-1

5. Go back to Session branch and Save it and then click Open.

6. Log in using your account details and try running “firefox”. It should be working by now.

Thus, your PHPUnit functional tests should be able to run using Firefox as well.

Generally speaking, you should now be able to run X applications from the server on your local desktop.

Also, make sure that the following are set to “yes” in your server’s /etc/ssh/sshd_config

X11Forwarding

X11UserLocalhost

: )

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s