While logged in remotely as ROOT, I want to run my selenium program remotely on ROOT's display (and not my remote display). I am not talking about doing ssh -X (which works), but instead I have one nodejs application spawning another nodejs application that uses selenium, all automatically without any user ssh'ing. But selenium needs to use a display of some sort in order to render some jpg files I need.
There are tons of questions that I've been looking at, but I am still struggling with the concept... The main sources of information that I've been using are:
- Open a window on a remote X display (why "Cannot open display")? (This has the most info)
- Can I launch a graphical program on another user's desktop as root?
- All answers by @Gilles :)
Here's what I understand:
- An X program needs two pieces of information in order to connect to an X display.
$DISPLAY- Typically
:0or:1. - When I physically go to the laptop and view root's display (instead of remotely ssh'ing in), the
$DISPLAYis set to:0or:1.
- Typically
$XAUTHORITY- The Magic Cookie to use is defined in
~/.Xauthorityand the environment variable$XAUTHORITY. - When I physically go to the laptop (instead of remotely ssh'ing in), the
$XAUTHORITYis set to/tmp/xauth-0-_0(when$DISPLAY=:0) or/tmp/xauth-0-_1(when$DISPLAY=:1).
- The Magic Cookie to use is defined in
=====================
Attempts
I've tried all these things:
Setting
$DISPLAYand$XAUTHORITYthrough a scriptI have a script that spawns the nodejs selenium application. I exported these two variables in the script first before running the selenium application:
if [ -e "/tmp/xauth-0-_0" ] then export DISPLAY=":0" export XAUTHORITY="/tmp/xauth-0-_0" elif [ -e "/tmp/xauth-0-_1" ] then export DISPLAY=":1" export XAUTHORITY="/tmp/xauth-0-_1" fi #Then run the nodejs selenium app node index.jsThe error I get when I use this method is
Invalid MIT-MAGIC-COOKIE-1 key[10332:10332:0713/112221.602744:ERROR:browser_main_loop.cc(272)] Gtk: cannot open display: :0.0
- Setting
X11Forwarding yesin/etc/ssh/sshd_config, but I think this only applies tossh -X Here are my other attempts at opening chrome:
[root@localhost test]# xauth list localhost:0 MIT-MAGIC-COOKIE-1 .... [root@localhost test]# export XAUTHORITY=/tmp/xauth-0-_0 [root@localhost test]# export DISPLAY=localhost:0 [root@localhost test]# google-chrome [10673:10673:0713/141603.418401:ERROR:browser_main_loop.cc(272)] Gtk: cannot open display: localhost:0 [root@localhost test]# export DISPLAY=127.0.0.1:0 [root@localhost test]# google-chrome [10859:10859:0713/141617.346302:ERROR:browser_main_loop.cc(272)] Gtk: cannot open display: 127.0.0.1:0
I am using Fedora 23 (Server Edition) x86_64
DISPLAY=:0and then trying to start a gui programm or did you just try your script + the weird localhost displays? – Ziazis Jul 14 '17 at 08:52DISPLAY=:localhost:0would use a local tcp connection. Most X servers disable this for security reasons. Try unix socket connection withDISPLAY=:0orDISPLAY=:unix:0instead. Unix sockets of X reside in/tmp/.X11-unix/– mviereck Jul 16 '17 at 15:41DISPLAY=:unix:0butDISPLAY=unix:0– mviereck Jul 16 '17 at 15:55