Ubuntu: X11 errors over SSH [duplicate]



Question:

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.


Solution:1

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.


Solution:2

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 .

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »