19

I'm attempting to set up x11 forwarding to monitor video on an embedded robotics platform yet I cannot seem to get the board to generate graphical output. I'm running Arch Linux on a Beagleboard xM wired directly over ethernet (though, I plan to use WiFi in the future). When I try to set the DISPLAY variable it will accept it but when I attempt to run an x11 application is says:

(Object:287): Gtk-WARNING **: cannot open display: [displaynamehere]

obviously [displaynamehere] was whatever I tried to set as the display, yet no display location seemed to work. What's weird is that whenever I connect through ssh -X it does not give me any errors and it does not save my DISPLAY variable.

(EDIT) I also checked the debug log and got this output:

debug2: load_server_config: filename /etc/ssh/sshd_config
debug2: load_server_config: done config len = 315
debug2: parse_server_config: config /etc/ssh/sshd_config len 315
debug3: /etc/ssh/sshd_config:53 setting AuthorizedKeysFile .ssh/authorized_keys
debug3: /etc/ssh/sshd_config:75 setting ChallengeResponseAuthentication no
debug3: /etc/ssh/sshd_config:96 setting UsePAM yes
debug3: /etc/ssh/sshd_config:101 setting X11Forwarding yes
debug3: /etc/ssh/sshd_config:104 setting PrintMotd no 
debug3: /etc/ssh/sshd_config:108 setting UsePrivilegeSeparation sandbox     
debug3: /etc/ssh/sshd_config:124 setting Subsystem sftp /usr/lib/ssh/sftp-server
debug1: sshd version OpenSSH_6.3, OpenSSL 1.0.1e 11 Feb 2013
debug3: Incorrect RSA1 identifier
debug1: read PEM private key done: type RSA
debug3: Incorrect RSA1 identifier
debug3: Could not load "/etc/ssh/ssh_host_rsa_key" as a RSA1 public key
debug1: private host key: #0 type 1 RSA
debug3: Incorrect RSA1 identifier
debug1: read PEM private key done: type DSA
debug3: Incorrect RSA1 identifier
debug3: Could not load "/etc/ssh/ssh_host_dsa_key" as a RSA1 public key
debug1: private host key: #1 type 2 DSA
debug3: Incorrect RSA1 identifier
debug1: read PEM private key done: type ECDSA
debug3: Incorrect RSA1 identifier
debug3: Could not load "/etc/ssh/ssh_host_ecdsa_key" as a RSA1 public key
debug1: private host key: #2 type 3 ECDSA
debug1: rexec_argv[0]='/usr/bin/sshd'
debug1: rexec_argv[1]='-ddd'
debug3: oom_adjust_setup
Set /proc/self/oom_score_adj from 0 to -1000
debug2: fd 3 setting O_NONBLOCK
debug1: Bind to port 22 on 0.0.0.0.
Bind to port 22 on 0.0.0.0 failed: Address already in use.
debug2: fd 3 setting O_NONBLOCK
debug3: sock_set_v6only: set socket 3 IPV6_V6ONLY
debug1: Bind to port 22 on ::.
Server listening on :: port 22.

Any suggestions would be greatly appreciated, I've been trying at this with google for almost a week now to no avail.

Thanks a lot!

SuperUser320
  • 248
  • 1
  • 2
  • 10
  • 2
    X11 forwarding may be disabled in the sshd_config on the remote system, which is why you would not see a DISPLAY variable set once you connect. You need to enable X11 forwarding: `X11Forwarding yes` and restart the ssh service on the remote system. Do not bother with `xhost` - most modern X11 servers don't listen on tcp by default and enabling it is a security risk. – Anya Shenanigans Oct 25 '13 at 12:46
  • I knew I was forgetting something. I neglected to mention that I do have that enabled in my sshd_config file. Do I need to enable any of the other X11 options? I've tried setting the X11DisplayOffset and X11UseLocalhost too to see if I could get it to work. Any way I do it my DISPLAY is still empty. – SuperUser320 Oct 28 '13 at 11:53
  • 1
    You should not need either X11DisplayOffset or X11UseLocalhost, but check with `ssh -vvv -X remotehost` and make sure it's specifying that initiating the remote X connection. If this information indicates that it is working, then there is a possibility that the shell you're logging into is clearing the DISPLAY environment variable as part of logging in. – Anya Shenanigans Oct 29 '13 at 08:32
  • I just ran that. It does not appear to initialize anything to do with the X server at all, just cipher, keys and connection negotiations. Is it possible that I don't have all the required packages for the X-server to start on connection? Thanks a lot for the time and help. – SuperUser320 Oct 29 '13 at 12:01
  • This seems suspicious: `Bind to port 22 on 0.0.0.0 failed: Address already in use.` it's running multiple times? – Anya Shenanigans Oct 29 '13 at 12:32
  • That's a good question. I ran a `top` command and only see one instance of sshd, but didn't see any other relevant tasks. Or duplicates of tasks for that matter. However, I don't see any X11 related processes running either. – SuperUser320 Oct 30 '13 at 03:05
  • it sounds like it's already running when you try to restart it. Because you're running a headless system, I would not expect any X processes running on the client either – Anya Shenanigans Oct 30 '13 at 09:09
  • Well, I found the fix. Complete novice mistake, I assumed I had all the packages because when I connected with `-X` it didn't complain, however I needed to install the `xorg-server` package. From there it has worked flawlessly. Thanks for the help! – SuperUser320 Oct 31 '13 at 01:59

3 Answers3

37

On the server

Edit /etc/ssh/sshd_config:

AllowAgentForwarding yes
AllowTcpForwarding yes
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost no

Restart the sshd daemon:

sudo service sshd restart
# or
sudo /etc/init.d/ssh restart
# or whatever way of restarting your box services works on your distro...

Install the packages (Ubuntu/Debian):

apt-get -y update
apt-get -y install xauth

Install the packages (RHEL/CentOS):

yum -y update
yum -y install xauth

Now exit the server:

exit

On the client

Set the DISPLAY environment variable locally:

export DISPLAY=:0.0

and start a trusted SSH connection to the server:

ssh -Y $ssh_user@$ssh_server

Verify success with a graphical app. Install an app supporting X11 forwarding, if needed. As an example:

yum -y install xclock

and action:

for i in {1..3} ; do bash -c "xclock &" ; done ;
frainfreeze
  • 567
  • 6
  • 20
Yordan Georgiev
  • 5,114
  • 1
  • 56
  • 53
  • 1
    Thanks a ton. I have tried a lot of answers but yours finally made it work. – user568109 May 31 '15 at 08:04
  • Is "`service`" something every Linux server has, or is that a program you knew the OP had because his server was running Arch Linux? Because I tried `sudo apt-get install service` on a GCloud Compute Instance and got nothing. Then I tried `sudo apt-cache search service` and also found nothing. I'm going to feel really stupid if it was meant to be something else (ie. I might say `cat [filename]`, but if a newbie typed `cat [filename]` into a terminal, clearly they would be confused) – Nathan majicvr.com Aug 21 '19 at 06:50
  • For me, `/etc/init.d/ssh restart` worked. I'm assuming it's because my machine is Debian/Ubuntu, ([more reading here](https://www.cyberciti.biz/faq/howto-restart-ssh/)) – Nathan majicvr.com Aug 21 '19 at 07:48
  • Other future users may want to put a "`sudo`" in front, making it `sudo /etc/init.d/ssh restart` – Nathan majicvr.com Aug 22 '19 at 04:47
3

Whenever I had this problem it was almost always about following two options, I think you should set them as below before making any further changes on your configuration like setting DISPLAY, etc.

X11Forwarding yes
X11UseLocalhost no
Baris Demiray
  • 1,539
  • 24
  • 35
1

ssh should set the DISPLAY automatically. usual suspects: missing "X11Forwarding yes" in /etc/ssh/sshd_config

To debug you can run verbose mode on the client and server and you may notice something : try on the "server" side (debug mode, no daemon)

$ /usr/sbin/sshd -d -p 222

on the "client":

$ ssh -v -Y phil@192.168.0.14 -p 222

Once in a while I meet an odd thing, like 'missing xauth' ...

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
phil_w
  • 1,204
  • 11
  • 8