Skip navigation

Connect to your Linux computer remotely without needing to take the less secure VNC route yet, still having a GUI to work with. This quick and painless tutorial will show how to forward your GNOME session from your Linux box to another computer, via SSH and X11 Forwarding. I have found out along the way that X11 forwarding seems quicker then a traditional VNC connection and has better integration. Better security and (what seems like) quicker response times are just one of the benefits of using SSH. You will of course need a OS that has X11 and GNOME installed for this experiment. This tutorial can also be applied towards other desktop environments as-well such as KDE if you wish and for individual applications.

Requirements

  • Two computers
  • One Computer running X11
  • One Computer running X11 and GNOME
  • Static IPs set
  • General knowledge of Linux
  • About 20-30min Free time

Step One

Set-up SSH on the Linux server, on Ubuntu Linux type sudo apt-get install SSH in the terminal and press enter. Type your admin password in and SSH should now be successfully installed.

Step Two

X11 forwarding is turned off by default when SSH is installed on your Linux server, it is now your task to turn it on. Type sudo  gedit /etc/ssh/ssh_config into terminal and press enter. Add

ForwardAgent yes
ForwardX11 yes
ForwardX11Trusted yes

to the file ssh_config and save it.

Repeat Step Two for the sshd_config file type sudo gedit /etc/ssh/sshd_config into the Linux terminal and press enter. Add

X11Forwarding yes

to the file sshd_config and save it.

Step Three

Connecting via SSH

Now from Mac OS X (any OS with x11 installed) type ssh -X username@server.ip.address into the X11 terminal (xterm) located inside the Utilities folder on Mac OS X. You will then be connected via SSH to the server.

Step Four

Typing Gnome-Session

After your connected to the server via SSH type gnome-session into the xterm terminal. It may take a second but you should see the start-up sequence for GNOME. Enjoy!

Advertisements

34 Comments

  1. Nice tip, thanks 🙂

    Problems are:
    – gnome menu bar and bottom bar are disappearing from the screen
    – double clicking on desktop files deosn’t seem to work
    – when opening in mac X11, the mouse is parasited (transformed to text pointer) by the X11 terminal windows

    • Scott
    • Posted January 13, 2008 at 6:54 pm
    • Permalink

    How about a tutorial on forwarding an X11 session to a Windows computer running cygwin?

    • Ronny
    • Posted January 13, 2008 at 7:04 pm
    • Permalink

    Great guide.
    “IPs”, not “IP’s”.

    If you drive “cars” and not “car’s”, fly in “airplanes” and not “airplane’s”, then you should be also:
    -Configuring PCs (not “PC’s”)
    -Listening to “CDs” (not “CD’s”)
    -Watching “DVDs” (not “DVD’s”)

    -Ronny

    • Ronny
    • Posted January 13, 2008 at 7:05 pm
    • Permalink

    There’s also the issue of “quicker then”…

    -Ronny

    • Steven
    • Posted January 13, 2008 at 7:32 pm
    • Permalink

    @Ronny – What are you, a f**king english teacher? It’s a technical guide, not a f**king spelling test.

  2. @Alexandre Girard

    I’ve only tested the instructions of this tutorial in 10.4 Tiger. Everything seemed to be working for me. Which version of OS X are you using and do you have the latest version of X11?

    • James
    • Posted January 13, 2008 at 7:36 pm
    • Permalink

    Scott: You should basically be able to follow the same set of instructions for Windows. Just make sure you have X11 installed in your cygwin install, and you have PuTTY (Google if necessary). Open the cygwin terminal. Type “startx” (no quotes). Then open PuTTY and make sure X11 Forwarding is enabled. That’s the gist of it.

    • Brian
    • Posted January 13, 2008 at 8:35 pm
    • Permalink

    Ronny iz a pees of shyte. There, suck on that you commie bastard.

    BTW, nice article!

    • Abuse
    • Posted January 13, 2008 at 9:17 pm
    • Permalink

    Comment abuse makes me smile. Ronny, you’re not making friends here!

    • Abuse
    • Posted January 13, 2008 at 9:19 pm
    • Permalink

    Bookmarked. Thanks for the article!!!

  3. Why not just use NoMachine? Much easier.

  4. Why would you want to overwrite your existing config files, though? Why not just use sudo/gksudo to run gedit as root and directly edit the existing config files? Or even back up the config files, add the necessary options, then overwrite the originals.

    • Cory
    • Posted January 14, 2008 at 1:14 am
    • Permalink

    Thank you for the basic walk through. I agree with B-Con, I just back up the config files, then directly overwrite them in the correct directory. The way you did it added a lot of uneccessary steps and clutter in your writeup. Also I’m not using Gnome, I found that typing xfce4-session launches a xfce desktop. It might be handy for others if you’d note these other desktop options in your write up.

    • Olev
    • Posted January 14, 2008 at 4:54 am
    • Permalink

    Oh, and one important thing. You do not need to have static IPs set. That is not a required to run X11 or SSH.

    • Jorixine
    • Posted January 14, 2008 at 6:49 am
    • Permalink

    what about the menus desapearing?
    when i go throgh de bar menus they desapear and appear…
    it seems to have to sessions on the same desktop… could you start other x session directly?

    • Jorixine
    • Posted January 14, 2008 at 7:00 am
    • Permalink

    so sorry for my horrible english in the last post…
    its too early for me here in Argentina

  5. @Jorixine
    You can just forward single application instead of the entire GNOME desktop, that should solve that problem. Instead of typing “ssh -X username@server.ip.address” then type in your app in such as “firefox”.

    Hope that helps 🙂

    • David
    • Posted January 14, 2008 at 9:33 am
    • Permalink

    Ronny, both IP’s and IPs are acceptable and proper in English.

  6. @Olev

    While it is not required to set static IPs to “run” SSH. Why would you even use SSH if you can’t connect to it from another computer?

    • MarK
    • Posted January 14, 2008 at 2:51 pm
    • Permalink

    I have done this with KDE and it works in 10.4, But when I upgrade to 10.5 the desktop would be stuck on top of every thing so it made work in possible. I just ran the kicker instead of full blown KDE

  7. @B-Con

    You guys are going to have to excuse me I wrote up this article awhile ago. So I’m trying to read it over again to get the gist of what I was doing then. Apparently this is not the most streamlined approach! It does work, even though there are a few unnecessary steps. 😉

    I’ll try and clean it up a tad.

    • wcarlson
    • Posted January 16, 2008 at 9:21 am
    • Permalink

    NO! Do not use mv, this will reset the permissions on the file to that of the new file!

    Example:

    [wcarlson@g wrk]$ touch testfile testfile1
    [wcarlson@g wrk]$ chmod 600 testfile1
    [wcarlson@g wrk]$ v testfile*
    -rw-r–r– 1 wcarlson users 0 Jan 16 10:18 testfile
    -rw——- 1 wcarlson users 0 Jan 16 10:18 testfile1
    [wcarlson@g wrk]$ mv testfile1 testfile
    mv: overwrite `testfile’? y
    [wcarlson@g wrk]$ v testfile*
    -rw——- 1 wcarlson users 0 Jan 16 10:18 testfile

    Editting the files directly is the correct answer, followed close;y by cp _newfile_ _oldfile_.

  8. @wcarlson

    Thanks for the insight, I have went ahead and changed the commands to “sudo gedit”. That should save the existing permissions, correct?

    Plus its much easier to do it that way, instead of the old “gedit” >> save to desktop >> “mv”. 🙂

  9. NX is easier and a lot sexier

  10. I’m actually just getting Gtk-Warning **: cannot open display on my gf’s MAC book running 10.4

  11. @Stubbs

    Are you typing the “ssh -X” command in normal OS X Terminal? You need to type this in the X11 terminal located in Applications >> Utilities (You might need to download it or install it from the OS X install disk).

    Hope that helps

    • Tone
    • Posted January 27, 2008 at 9:25 am
    • Permalink

    Hi, I’m also getting “Gtk-WARNING **: cannot open display:”
    on OSX 10.3.9 (also owned by GF)
    Is there anything else that needs to be installed on the Mac?

  12. thanks for the article, i’ll give it a try.

    • mieses
    • Posted January 27, 2008 at 5:01 pm
    • Permalink

    Forwarding X and Gnome over SSH seems slower (10 – 100x slower) than VNC when connecting remotely (DSL, Cable modem, etc).

    I’m using Xming + putty to connect from Windows to a remote Linux box. I tried SSH protocol compression. It made things even slower.

    Are you saying that X forwarding shouldbe faster for LAN or for remote connections?

    • Matt
    • Posted April 11, 2008 at 1:49 am
    • Permalink

    Your blog make me chuckle from beginning to end^_^!! It sounds absolutely great to me. Your blog is my favorite!

    • Jon
    • Posted October 27, 2008 at 10:40 pm
    • Permalink

    This also did not work under OSX 10.5.5. I loaded xterm up in X11.app as one of the comments pointed out but I still get the symptoms of the desktop not being clickable. The remote server is fedora 9 if that matters. Advice? Did anyone actually get this working?

    • Anonymous
    • Posted February 3, 2009 at 4:07 pm
    • Permalink

    For OSX 10.5 (Leopard), you need to change the quartz-wm binary to use the –proxy-only option. Otherwise, you’ll get the odd windowing behavior. The best way to do this is to copy /usr/X11/lib/X11/xinit/xinitrc to ~/.xinitrc and edit the new file to include the /usr/X11/lib/X11/xinit/xinitrc.d/99-quartz-wm.sh file with the –proxy-only option.

  13. That works great for me using Xming under windows to acces a remote Red hat server 🙂

  14. Hey,

    Great tutorial!

    The only problem is that after running gnome-session my whole keyboard seems to be upside down.
    What I mean is that 1-9 seem to have become ertyui]p, the backspace is at j and the , on backspace. Weird isn’t it? This is true for every single key on my keyboard. Feels strange to type a with the caps key and find yourself typing uppercase after pressing f.

    Before I started gnome-session it worked fine… But I can’t find my way in Ubuntu without the menu. What is the default keyboard layout used before starting gnome-session?


12 Trackbacks/Pingbacks

  1. By purrl.net |** urls that purr **| on 13 Jan 2008 at 5:03 pm

    This is one of the web’s most interesting stories on Mon 14th Jan 2008

    These are the web’s most talked about URLs on Mon 14th Jan 2008. The current winner is ..

  2. By Run Gnome remotely « 0ddn1x: tricks with *nix on 14 Jan 2008 at 2:12 pm

    […] Run Gnome remotely Filed under: Linux, Security — 0ddn1x @ 2008-01-14 21:12:21 +0000 http://infectedproject.com/2007/07/09/forwarding-gnome-via-ssh/ […]

  3. […] Forwarding GNOME via SSH This quick and painless tutorial will show how to forward your GNOME session from your Linux box to another computer, via SSH and X11 Forwarding. (tags: tutorial howto ssh x11 gnome gui remote remotedesktop) […]

  4. By links for 2008-01-15 « Bloggitation on 14 Jan 2008 at 5:19 pm

    […] Forwarding GNOME via SSH (tags: ubuntu vpn sysadmin) […]

  5. By links for 2008-01-15 « Mike Does Tech on 14 Jan 2008 at 5:36 pm

    […] Forwarding GNOME via SSH […]

  6. By Linux Guide #1 | Ptolemaidas Linux Users Group on 16 Jan 2008 at 7:39 am

    […] Ένα πολύ χρήσιμο how-to για το πώς θα δουλεύετε GNOME μέσω SSH. http://infectedproject.com/2007/07/09/forwarding-gnome-via-ssh/ […]

  7. […] Forwarding GNOME via SSH […]

  8. By connect X11 from SSH. « Happy Every Day. on 30 Jan 2008 at 1:14 pm

    […] the X11 is running gnome, try the following steps: (I haven’t […]

  9. By bernie actor on 09 Feb 2008 at 2:52 pm

    bernie actor

    Thanks for the nice read, keep up the interesting posts..

  10. By jamie king on 14 Feb 2008 at 5:02 am

    jamie king

    Man i just love your blog, keep the cool posts comin..

  11. By Top Desktop Computers on 15 Apr 2008 at 10:17 pm

    Top Desktop Computers…

    I know nothing except the fact of my ignorance. ~ Socrates…

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

%d bloggers like this: