Access Remote GUI Programs Using SSH Forwarding

May 21st, 2009 by Shawn Powers in

Your rating: None Average: 4.5 (27 votes)

Run GUI apps on another machine remotely through SSH.

Download in .ogv format
__________________________
Shawn Powers is an Associate Editor for Linux Journal. You might find him chatting on the IRC channel, or Twitter


Special Magazine Offer -- Free Gift with Subscription
Receive a free digital copy of Linux Journal's System Administration Special Edition as well as instant online access to current and past issues. CLICK HERE for offer

Linux Journal: delivering readers the advice and inspiration they need to get the most out of their Linux systems since 1994.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anonymous's picture

Root + SSH = No Go!

On August 26th, 2009 Anonymous (not verified) says:

You really shouldn't allow root to login remotely!

That even counts double if you're using plain old password to log in!

You get much more security if you use ssh keys to login and don't allow root to log in remotely. Instead, log in as a normal user and use the command "su -" or "sudo" to become root *after* you have logged into the remote machine.

Last, but not least, don't use port 22 for ssh. Set sshd to listen to some other port > 1024.

Easteregg's picture

I like it! shows that linux

On May 30th, 2009 Easteregg (not verified) says:

I like it! shows that linux has something to say :D

Anonymous's picture

The first time i ran the

On May 28th, 2009 Anonymous (not verified) says:

The first time i ran the command it just worked.. I was really impressed. My server has a 5Mbit upload, so the performance was not bad at all..

however, the next day, and every day since i get the following error when i try the command.

(gnome-terminal:27725): Gtk-WARNING **: cannot open display:

CentOS 5.3 Final

copsewood's picture

Display Linux apps on a Windows desktop too

On May 26th, 2009 copsewood (not verified) says:

I found out how to make a Windows desktop display Linux apps also using the remote X display protocol a couple of weeks ago. The SSH client to use on Windows is Putty and you need to set this in X forwarding mode, and also have the Xming X server on Windows running in multiwindow mode.

If the Linux server is on a broadband connection, you will probably need to forward the SSH port to it from the router/firewall. If the server is running Ubuntu, make sure you run the command:

sudo aptitude install openssh-server

to install and run the SSH server on it too.

Oh and BTW, good idea to install denyhosts or similar on the ssh server to defeat password guessing attacks.

headlice's picture

ssh -C server2@address -p

On May 23rd, 2009 headlice (not verified) says:

ssh -C server2@address -p gnome-terminal

Outputs this:

Failed to contact the GConf daemon; exiting.

David Murch's picture

server setup

On May 23rd, 2009 David Murch (not verified) says:

To setup a machine to connect to with SSH forwarding simply do the following (ubuntu + SuSe:

make sure to install the package openssh-server on your distro

> vi /etc/ssh/sshd_config

and set:
X11Forwarding yes

> vi /etc/ssh/ssh_config

and set:
ForwardAgent yes
ForwardX11 yes
ForwardX11Trusted yes

> /etc/init.d/ssh restart

Your done and con connect with forwarding

The Other Richard's picture

I see a red arrow on the top

On May 22nd, 2009 The Other Richard (not verified) says:

I see a red arrow on the top bar. Don't forget to install your updates.

Yes, this is great for LAN not so much for WAN. But for WAN, ssh to a command line is not so hard. Don't fear the command line. After the learning curve you can accomplish more in quicker time.

And yes, this is from someone who on WinXP has evolution open on a linux box and another ssh xterm shell open to control a OSX box. :)

Anonymous's picture

Thats fascinating but what

On May 22nd, 2009 Anonymous (not verified) says:

Thats fascinating but what is required to get that up and running, i.e maybe instead of showing us to use a feature explain how it is setup i.e. how to enable/configure X forwarding, or am to understand that this is just a teaser?

GX

madspaz's picture

Cool

On May 21st, 2009 madspaz (not verified) says:

Been using !NX for some time now to get a remote X session; not quite as simple but with Debian it can be a 3 click process (using the .deb files, literally up and running in 5 minutes) once OpenSSH is installed. Great tip none the less; yes it is slow but more than enough in a bind.

terry's picture

local network will not work

On May 21st, 2009 terry (not verified) says:

I used a ip from a laptop on my local network with this command

( ski@ubuntu:~$ ssh -C -X ski@192.168.X.XXX )

also tried root before the @ sign.came back as

ssh: connect to host 192.168.x.xxx port 22: Connection refused

NOTE :I blocked my local ip with XXs for example only.

Shawn Powers's picture

SSH?

On May 21st, 2009 Shawn Powers says:

Perhaps SSH isn't running on your server?

__________________________

Shawn Powers is an Associate Editor for Linux Journal. You might find him chatting on the IRC channel, or Twitter

Jason's picture

too slow

On May 21st, 2009 Jason (not verified) says:

This tip is too slow for anything except local area network.

Shawn Powers's picture

Sorta

On May 21st, 2009 Shawn Powers says:

Yes, over a WAN it is pretty painful to use an application -- but for an emergency configuration or something, it's tolerable over broadband.

__________________________

Shawn Powers is an Associate Editor for Linux Journal. You might find him chatting on the IRC channel, or Twitter

Anonymous's picture

Sneakiness

On May 21st, 2009 Anonymous (not verified) says:

What you really need to show people is how to get around corporate firewalls and web filters by using linux on a home computer to act as a proxy both for HTTP/S and for DNS. The same techniques are also handy for safe web access in places like airports, hotels, and conventions.

Just a suggestion.

Post new comment

Please note that comments may not appear immediately, so there is no need to repost your comment.
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <pre> <ul> <ol> <li> <dl> <dt> <dd> <i> <b>
  • Lines and paragraphs break automatically.

More information about formatting options

Newsletter

Each week Linux Journal editors will tell you what's hot in the world of Linux. You will receive late breaking news, technical tips and tricks, and links to in-depth stories featured on www.linuxjournal.com.
Sign up for our Email Newsletter

Tech Tip Videos

From the Magazine

December 2009, #188

If last month's Infrastrucuture issue was too "big" for you then try on this month's Embedded issue. Find out how to use Player for programming mobile robots, build a humidity controller for your root cellar, find out how to reduce the boot time of your embedded system, and if you're new to embedded systems find out the basics that go into one. You can also read about the Beagle Board, the Mesh Potato and a spate of other interestingly named items. And along with our regular columns don't miss our new monthly column: Economy Size Geek.


Read this issue