5

i get following errors when trying to open programs over ssh.

$ thunar
Thunar: Cannot open display: 

$ libreoffice 
Failed to open display

$ firefox
Error: GDK_BACKEND does not match available displays

$ keepassx
keepassx: cannot connect to X server 

$ keepass2
Unhandled Exception:
System.TypeInitializationException: The type initializer for 'System.Windows.Forms.XplatUI' threw an exception. ---> System.ArgumentNullException: Could not open display (X-Server required. Check your DISPLAY environment variable)
Parameter name: Display
  at System.Windows.Forms.XplatUIX11.SetDisplay (IntPtr display_handle) <0x41b3c8a0 + 0x00b9b> in <filename unknown>:0 
  at System.Windows.Forms.XplatUIX11..ctor () <0x41b3ab20 + 0x001df> in <filename unknown>:0 
  at System.Windows.Forms.XplatUIX11.GetInstance () <0x41b3a8d0 + 0x0005b> in <filename unknown>:0 
  at System.Windows.Forms.XplatUI..cctor () <0x41b3a160 + 0x00137> in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Windows.Forms.Application.EnableVisualStyles () <0x41b38870 + 0x0001b> in <filename unknown>:0 
  at KeePass.Program.Main (System.String[] args) <0x41b376c0 + 0x0008b> in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'System.Windows.Forms.XplatUI' threw an exception. ---> System.ArgumentNullException: Could not open display (X-Server required. Check your DISPLAY environment variable)
Parameter name: Display
  at System.Windows.Forms.XplatUIX11.SetDisplay (IntPtr display_handle) <0x41b3c8a0 + 0x00b9b> in <filename unknown>:0 
  at System.Windows.Forms.XplatUIX11..ctor () <0x41b3ab20 + 0x001df> in <filename unknown>:0 
  at System.Windows.Forms.XplatUIX11.GetInstance () <0x41b3a8d0 + 0x0005b> in <filename unknown>:0 
  at System.Windows.Forms.XplatUI..cctor () <0x41b3a160 + 0x00137> in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Windows.Forms.Application.EnableVisualStyles () <0x41b38870 + 0x0001b> in <filename unknown>:0 
  at KeePass.Program.Main (System.String[] args) <0x41b376c0 + 0x0008b> in <filename unknown>:0 
:06:22 PM~/Documents$ gimp
Cannot open display: 

$ wireshark
QXcbConnection: Could not connect to display 
Aborted (core dumped)

$ gedit 
Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused

(gedit:23724): Gtk-WARNING **: cannot open display: 

i've always been able to open aplications over ssh, this just started yesterday. using ubuntu 16.04 on both machines.

please DO NOT flag this as a repeat question, the following solutions didn't help:

https://superuser.com/questions/310197/how-do-i-fix-a-cannot-open-display-error-when-opening-an-x-program-after-sshi

gksu: Gtk-WARNING **: cannot open display: :0

Gtk-WARNING **: cannot open display: on Ubuntu Server

(nautilus:13581): Gtk-WARNING **: cannot open display:

if specific info is needed, please ask, i'll do my best to answer.

  • How about this this post on trust level? Sounds pretty much the same... – Jeroen Jul 25 '16 at 23:35
  • thanks. i saw that link too. it didn't help. i just noticed $env reports no values or references to xauthority variables on the sshd server. could this be the reason for the x11 errors? there's no $DISPLAY or anything defined by default on the server. – assassin4321 Jul 25 '16 at 23:43
  • What happened yesterday? did you update, install or remove something? – Katu Nov 23 '16 at 09:36

2 Answers2

5

It is necessary for you to tell us 3 things.

  1. What command did you use to launch your ssh session.

Did you run

$ ssh -Y whatever.com

or

$ ssh -X whatever.com

If you had neither -X nor -Y, X11 forwarding won't work

  1. Have you edited the ssh client configuration file on the client machine? If you changed that, tell us exactly what.

If you don't want to type -X every time you need X11 forwarding, it can be set as default by editing /etc/ssh/ssh_config. That's not the machine's server config, it is default for all clients. At the bottom of mine, I have

ForwardAgent yes
ForwardX11 yes
ForwardX11Trusted yes

I expect these changes will have no effect until you log out, but I may be wrong about that.

  1. On the server machine, did you enable X11 forwarding?

On the server, in the file /etc/X11/sshd_config, it will be necessary to turn on X11 forwarding with a line like

X11Forwarding yes

Please note that change will not have an effect until the server is restarted, or at least its ssh server is restarted.

Let us know how that works. If it fails, report the config files and what you ran.

ardavis
  • 103
pauljohn32
  • 3,743
1

Have you disabled ipv6? If so I found the solution! Add AddressFamily inet to sshd_config.

Edit:

Perform the following steps:

  1. On the server, edit the file /etc/ssh/sshd_config .
  2. The default file should have "AddressFamily inet" commented out. Uncomment it and change the value from its default of "any" to "inet".
  3. Then restart the service: sudo service sshd restart .
Ray
  • 2,071
Alroger Jr
  • 11
  • 1
  • @wjandrea I think it's great to encourage new users to refine their answers but let's balance that with the possibility of being too demanding. Because a new user could also decide, "Oh! Forget it...I'm just trying to help and it's just too much trouble! I won't post anything!". Just my point of view. I had the problem mentioned and Alroger Jr's solution was exactly what I needed; for someone who knows Ubuntu even a little, a "man sshd_config" would answer your questions. I'll try to edit his post with the information you ask for. – Ray Dec 04 '17 at 15:02