# running graphical apps via ssh

## azambuja

hello,

i have a gentoo box at home, with static ip address and sshd running. it has X, KDE, GNOME, etc installed. In my university there are linux boxes with red hat 7.3, also with X, KDE, GNOME...

The computers in the university are not accesible outside of it (i guess they have internal ips)...

what im trying to do is to connect home with ssh thru this computers. I connect properly, but i cant run graphical apps (i get the error: cant connect to x server)

i guess doing 

```
export DISPLAY="university ip"
```

 wont help, since this ip is not acessible outside.

any help?

thanx/cheers

----------

## Crg

 *azambuja wrote:*   

> 
> 
> i guess doing 
> 
> ```
> ...

 

Have you got ssh X forwarding turned on?

----------

## mr45acp

That's right. No need to set DISPLAY. Actually, it just breaks the ssh built-in X forwarding. Just make sure sshd_conf ig says





```
X11Forwarding yes
```

----------

## nitro322

and, of course, you'll need to use -X when sshing to the remote box:

```
ssh -X server
```

----------

## ph_flippy

 *nitro322 wrote:*   

> and, of course, you'll need to use -X when sshing to the remote box:
> 
> ```
> ssh -X server
> ```
> ...

 

Or you uncomment the line 

```
Forward X11 yes
```

 in /etc/ssh/ssh_config. Then you have it enabled globally and every time.

----------

## azambuja

ok guys,

but... im a mere user in that computer, which means i have no root access, just normal user...

cheers

----------

## ph_flippy

So you want to connect to your Gentoo-box at home from the university?

And you do have root-access on your Gentoo-box at home, I should think.

What you need to do is this:

On your Gentoo-box at home, edit the file /etc/ssh/sshd_config and uncomment the line (as suggested by mr45acp)

```
# X11Forwarding yes
```

 (maybe you have to change it from "no" to "yes").

Then on the university-machine typing 

```
ssh -X homeIP
```

 (as suggested by nitro322) should enable you to run graphical apps from your home gentoo-box, I think so anyway.

----------

## azambuja

ok, thanx... i´ll try that tomorrow

cheers

----------

## azambuja

no way, after enabling xforwarding in my machine in /etc/ssh/sshd_config, and running the command ssh -X my_ip from university I got no success...

maybe some ports are locked on the university cpu? Maybe its necessary that the university machine also have a real ip address?

cheers

----------

## nitro322

I know this sounds stupid, but did you restart sshd after changing sshd_config?  I have a bad habit of forgetting stuff like that...

If it still doesn't work, try manually setting your DISPLAY variable after connecting with ssh -X.  'export DISPLAY=localhost:10.0' should do the trick.  I've had to do this sometimes when, for whatever reason, this wasn't being set correctly at login.

----------

## azambuja

yes i have restarted the daemon...

the same problem occurs, typing:

```
export DISPLAY=localhost:10.0
```

or not...

cheers

----------

## headdriller

azambuja - 

Is it possible to run 'X -query <homeip>' from the boxes at work?  

And run xdm at home to serve remote X logins.  I've used this on my local LAN, but haven't used it enough to figure out SSH or other security issues. 

A thought.

-HeadDriller

----------

## Lasitus

You may already know this, but it caused me grief for about 2 minutes, when I was doing this for the first time.  You don't need to startx again on the forwarded computer.  It uses the instance of X that is on the computer you are using.  So, startx on the computer you are using and then ssh -X...  After that, all you need to do is run the graphical program in question.

----------

## azambuja

 *headdriller wrote:*   

> azambuja - 
> 
> Is it possible to run 'X -query <homeip>' from the boxes at work?  
> 
> And run xdm at home to serve remote X logins.  I've used this on my local LAN, but haven't used it enough to figure out SSH or other security issues. 
> ...

 

X -query gives this output:

```
Fatal server error:

Server is already active for display 0

        If this server is no longer running, remove /tmp/.X0-lock

        and start again.

If you encounter a server crash, please report the problem by filing a bug

report in the XFree86.org bugzilla at http://bugs.xfree86.org and/or Red Hat

bugzilla at http://bugzilla.redhat.com/bugzilla.  When filing your report, it

is very important that you explain your problem in as much detail as possible,

and include a complete description on how to reproduce the problem.  After

submitting the bug report, attach the following files as uncompressed

individual file attachments using the bugzilla file attachment feature:

        - Kernel log file: /var/log/messages
```

Lasitus: yes, that´s what i´ve been trying...

thanx/cheers

----------

## volrathxp

I've been trying to figure this out for some time as well.    :Confused: 

----------

## CdWhistler

This is what I did for X through ssh:

Enable "X11Forwarding yes" in sshd_config

Make sure you dont have a firewall running on your home machine or unblock  the ports that X needs.

Make sure you are in X on the computer you are connecting from.

Open an XTerm or whatever you use

Type Xhost +

This allows anyone to connect to your xserver.

Connect to your computer via ssh in an xterm or whatever

Do export DISPLAY="university ip"

Then type xclock or whatever program you want to run and it should show up on your screen.

I cant guarantee this will work but it does on my lan. YMMV. Good luck

----------

## mfairchi

 *Quote:*   

> export DISPLAY="university ip"

 

Unless I'm mistakken, if you do the above you are not using ssh as the tunnel for your X traffic.  You want to set DISPLAY=localhost:0 if you want the traffic to be picked up by the sshd daemon and forwarded thru the secure ssh connection to the client.

----------

## MJN222

 *CdWhistler wrote:*   

> Type Xhost +
> 
> This allows anyone to connect to your xserver.
> 
> 

 

Keep in mind that when you do 

```
xhost +
```

 anyone can connect to your computer. For security reasons it is generally preferable to specify the IP of the host (but that might not be possible in your case). Just be advised that if you xhost + anyone who wants to will be able to connect to your X server.

----------

## jsleeper

All that i've ever had to do is make sure X forwarding is enabled on the server...   Then from the client i do:

```
ssh -X hostname command
```

For example, sometimes if I use my debit card at lunch i'll go ahead and record it (from work) on my home computer by pulling up gnucash like this:

```
ssh -Xf <homeip> gnucash
```

I do this from an eterm so that the password dialog displays,and it puts ssh into the background while that process is running.   Then just close the app and the ssh session is also killed.

joe

----------

## Naan Yaar

What jsleeper mentions above is all you need to forward X over ssh.  You shouldn't have to set the DISPLAY variable on the remote (your home) machine explicitly.  You don't have to do xhost + on the client (univ. machine) either.  The best way to debug this would be to do:

```

ssh -v -v -X <homeIP>

xclock&

```

and then see what error messages you get.  You can also check sshd logs on your home machine in /var/log.

----------

## JHuizingh

It never hurts to ask... The machine you're using at your university has an X server right?  It's not windows is it?

----------

## dolbz

 *azambuja wrote:*   

> hello,
> 
> In my university there are linux boxes with red hat 7.3, also with X, KDE, GNOME...
> 
> 

 

I think that answers your question JHuizingh

Dolbz

----------

## JHuizingh

It sure does... Doh!

----------

## texx

How can i connect from an windows machine over ssh to my linux box an running x applications????

Have i only type 

```
ssh -X ip 
```

 like under *ix???

----------

## rlopez

I just set this up for a programmer at work who uses a Win2K machine and needs access to a Linux box for testing.

I installed Cygwin, with SSH and Xfree86 options.

There's a nice batch file you can click on that will start the Xserver on the windows machine and open an xterm window. From there I just do the following:

```
ssh -X -l userID IPaddress
```

Then he can launch GUI apps like this:

```
fluxbox &

xosview &
```

Note that fluxbox is not required to run xosview, just makes for an interesting experience.

----------

