You are not logged in.

#1 2017-09-12 20:31:18

xCoolGuyx
Member
Registered: 2017-09-12
Posts: 3

[SOLVED](SSH + Xorg): "Error: cannot open display: :0"

I set up an SSH daemon on another laptop and everything works well for the most part. I connect with

ssh -Y admin@192.168.0.222

perfectly, but when I try to run a graphical application like

firefox &

I'm returned

Unable to init server: Could not connect: Connection refused Error: cannot open display: :0

Xforwarding is enabled, here's my client config:

Host *
ForwardAgent yes
ForwardX11 yes
#   RhostsRSAAuthentication no
#   RSAAuthentication yes
#   PasswordAuthentication yes
#   HostbasedAuthentication no
#   BatchMode no
#   CheckHostIP yes
#   AddressFamily any
#   ConnectTimeout 0
#   StrictHostKeyChecking ask
#   IdentityFile ~/.ssh/identity
#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
#   IdentityFile ~/.ssh/id_ecdsa
#   IdentityFile ~/.ssh/id_ed25519
#   Port 22
#   Protocol 2
#   Cipher 3des
#   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
#   MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160
#   EscapeChar ~
#   Tunnel no
#   TunnelDevice any:any
#   PermitLocalCommand no
#   VisualHostKey no
#   ProxyCommand ssh -q -W %h:%p gateway.example.com
#   RekeyLimit 1G 1h
# 

And my server sshd_config:

AllowAgentForwarding yes
AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes
#PermitTTY yes
PrintMotd no # pam does that
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

Again, I can connect fine just not run GUIs. Running the wiki's

xhost +

returns

No protocol specified
xhost:  unable to open display ":0"

on both root and regular user.

$DISPLAY :0
$TERM xterm
$XAUTHORITY /home/admin/.Xauthority
[user]$ ps aux|grep X
root       551  0.0  0.6 1188900 52784 tty7    Ssl+ 21:40   0:00 /usr/lib/xorg-server/Xorg :0 -seat seat0 -auth /run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
admin      950  0.0  0.0   9108   884 pts/0    S+   22:13   0:00 grep X

Hostname is set. Maybe the issue is coming from running from tty and not a dedicated x? I'm not running NetworkManager, just netctl.

Last edited by xCoolGuyx (2017-09-12 22:40:29)

Offline

#2 2017-09-12 20:35:16

slithery
Member
Registered: 2013-12-01
Posts: 1,667

Re: [SOLVED](SSH + Xorg): "Error: cannot open display: :0"

Welcome to the forums xCoolGuyx smile

xCoolGuyx wrote:

Maybe the issue is coming from running from tty and not a dedicated x?

Correct.

You have to be running an X session to make use of X forwarding

Last edited by slithery (2017-09-12 20:35:56)

Offline

#3 2017-09-12 21:04:52

HiImTye
Member
From: Nanaimo, BC, Canada
Registered: 2012-05-09
Posts: 863

Re: [SOLVED](SSH + Xorg): "Error: cannot open display: :0"

if you have an X session running, X forwarding should work fine from a TTY. if not, then there's no running session to connect to

Offline

#4 2017-09-12 21:35:01

xCoolGuyx
Member
Registered: 2017-09-12
Posts: 3

Re: [SOLVED](SSH + Xorg): "Error: cannot open display: :0"

slithery wrote:

Welcome to the forums xCoolGuyx smile

xCoolGuyx wrote:

Maybe the issue is coming from running from tty and not a dedicated x?

Correct.

You have to be running an X session to make use of X forwarding

HiImTye wrote:

if you have an X session running, X forwarding should work fine from a TTY. if not, then there's no running session to connect to

I've scrapped my DM to work with bare X, and now I'm running into trouble. On

sudo startx

, I'm given

Xorg: privates.c:385: dixRegisterPrivateKey: Assertion `!global_keys[type].created' failed.
xinit: giving up
xinit: unable to connect to X server: Connection refused
xinit: server error

the documentation for which is nil. Google dorking only returns mailing list archives and bug trackers. However, I don't think this is an issue specific to Arch, as I've never been able to set up X properly on this particular machine ever. Messing with the Intel Xorg conf, I can get X up and running but with:

(==) Using system config directory "/usr/share/X11/xorg.conf.d"
Failed to connect to bus: No such file or directory
dbus-update-activation-environment: error: unable to connect to D-Bus: Using X11 for dbus-daemon autolaunch was disabled at compile time, set your DBUS_SESSION_BUS_ADDRESS instead

and running

firefox &

gets

No protocol specified
Unable to init server: Could not connect: Connection refused
Error: cannot open display: :0

and

root       692  0.0  0.0  16020  1052 pts/0    S    23:21   0:00 xinit /etc/X11/xinit/xinitrc -- /etc/X11/xinit/xserverrc :0 -auth /tmp/serverauth.v9H4fbvDIK
root       693  0.0  0.2 285888 23144 tty2     S<sl+ 23:21   0:00 /usr/lib/xorg-server/Xorg -nolisten tcp :0 -auth /tmp/serverauth.v9H4fbvDIK
admin      718  0.0  0.0   9108   964 pts/0    S+   23:24   0:00 grep X

X is obviously started on the main machine and I can launch Firefox and etc. there perfectly, but still not under SSH. I think it might be the `-nolisten tcp` and I'll try that next.

Edit:

Removing `-nolisten tcp` did nothing noticeable. Still at previous "No protocol .... cannot open display :0". Xhost still fucked. For a sanity check, I tried launching an xterm with no success.

Edit 2:

So we're getting somewhere now. Ran

xhost +

on the physical machine I'm trying to connect to instead of just the SSH terminal. I can now spawn firefox windows remotely, but I can't see them on my end which sucks.

Gonna mess with the confs some more.

Edit 3:

xhost +

isn't persistant. You're gonna have to place it in one the `xerverrc` files, mine's in `/etc/X11/xinit/xserverrc`. Otherwise programs return

No protocol specified
Unable to init server: Could not connect: Connection refused
Error: cannot open display: :0

Windows still only show up on the other machine when run through SSH.

Edit 4:

You need to mess with three configs now for whatever goddamn reason. Your ssh_config, and then the server's ssh_config and sshd_config. Enable everything that has to do with forwarding.

Last edited by xCoolGuyx (2017-09-12 22:36:50)

Offline

#5 2017-09-12 22:39:33

xCoolGuyx
Member
Registered: 2017-09-12
Posts: 3

Re: [SOLVED](SSH + Xorg): "Error: cannot open display: :0"

Finally got it solved by removing all hard-coded DISPLAY environment variables. Mine was in ~/.bashrc. I can now spawn GUI programs from another computer onto mine own. The implementation is slow as shit and I thought I'd just be getting the graphical rendering, while the server takes care of all the processing.

Offline

Board footer

Powered by FluxBB