0

I have the following setup: Machine A (a.corp, 192.168.100.130, local machine) and Machine B (b.corp, remote machine) and a monitor is connected to each of these machines. When I ssh from a.corp to b.corp as

Machine A, local machine, i.e., a.corp set up:

.ssh/config

Host *
    ForwardX11 yes
    TCPKeepAlive no
    ServerAliveInterval 15
    ServerAliveCountMax 10
    IdentityFile ~/.ssh/id_dsa.work

/etc/ssh_config (it is a OS-x, Darwin 12.2.0)

Host *
  SendEnv LANG LC_*
  ForwardX11 yes

MachineB, remote machine, i.e., b.corp setup: (ubuntu kernel: 3.2.0)

.ssh/config

Host * 
    ForwardX11 yes
    IdentityFile ~/.ssh/id_dsa.work

/etc/ssh/ssh_config

Host * 
    SendEnv LANG LC_*
    ForwardX11 yes

Case 1:

(DISPLAY on a.corp is not set)
$ echo $DISPLAY

$ ssh -X b.corp

(DISPLAY on b.corp is not set either)
$ echo $DISPLAY

$ xclock
Error: Can't open display:

Case 2: I tried setting the DISPLAY variable as

(DISPLAY on a.corp is not set)
$ echo $DISPLAY

$ ssh -X b.corp
$ export DISPLAY=`echo $SSH_CLIENT|cut -f1 -d\ `:0.0
$ echo $DISPLAY
192.168.100.130:0.0
$ xclock

xclock's display opens up but on the monitor connected to b.corp (remote machine) and not on the monitor connected to a.corp (local machine). Is there a way to force the display to appear on the monitor of the local machine (a.corp)?

1
  • 1
    192.168.100.130 is the ip of which machine?
    – Don Simon
    Nov 6, 2012 at 16:43

2 Answers 2

2

Normally, DISPLAY must be set to localhost:10.0 on the remote machine You should also ensure that /etc/ssh/ssh_config on the remote machine has the line

ForwardX11 Yes

Under the section

Host *

or

Host a.corp

if you want to allow X11 forwarding to this host only.

10
  • If this worked for you, please consider updating the question so other people with the same problem can fix it.
    – Joseph R.
    Nov 8, 2012 at 12:09
  • You meant DISPLAY on the local machine or remote machine. If I set DISPLAY on remote machine to localhost:10.0 I get Error: Can't open display: localhost:10.0. I have updated the question with the config settings on both local and remote machine.
    – Sumit
    Nov 8, 2012 at 18:28
  • I meant on the remote machine (modified the answer). This is usually set up by the -X switch, though; which makes me suspect that your configuration somehow blocks X11 forwarding. You mentioned looking in .ssh/config Which user's home were these in? Have you checked the system-wide files in etc/ssh/ssh_config ?
    – Joseph R.
    Nov 9, 2012 at 23:34
  • Joseph, I checked the system wide files as well. Nothing unusual there. I have updated the question with /etc/ssh_config information as well.
    – Sumit
    Nov 12, 2012 at 16:22
  • Well the system-wide files on machine B don't seem to indicate that it allows X11 forwarding. If you have the right privileges on machine B, try adding ForwardX11 Yes to /etc/ssh/ssh_config on it.
    – Joseph R.
    Nov 12, 2012 at 16:57
0

Try connecting without using xauth:

client@home: ssh server -Y xeyes

If this works, then you'll have to look into setting up x11 security properly.

4
  • As I stated in the comments above this works same as -X option
    – Sumit
    Nov 15, 2012 at 16:57
  • Are you running su to become another user or something? If DISPLAY is not set in the "xterm" that lives in your local x session, then there is nowhere to forward to. The DISPLAY variable must be set before you try to x-forward something to it from a remote host. Can you start xeyes or similar at all from the terminal emulator where you shell into the remote server? If you can't even start things locally, and you won't be able to do it unless DISPLAY is set, then it's no wonder forwarding isn't working. in case of su skip the - (new login shell). In case of sudo use the -E option. Nov 15, 2012 at 17:28
  • No I am not using su or sudo. And yes xeyes opens up fine, just not on the right screen (I have updated the questions with exact behavior observed)
    – Sumit
    Nov 15, 2012 at 19:44
  • Nothing will open "just fine" when DISPLAY isn't set. Export the variable as :0.0 and then try to shell to the remote host with -Y like I suggested. To use an ip in the DISPLAY on the remote host, the local host must have run xhost +remotehost.com. Make sure that 192.168.100.130 means what you think it does on the remote host - that is your local computer. Finally make sure there are no firewall rules that restrict this type of traffic. Nov 15, 2012 at 20:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.