Logging into a remote host using ssh -X [email protected], I successfully run gnome-terminal -e "tail -F /var/log/file" &. When I log off and then try the same thing the next day, I get this:
Failed to get the session bus: Failed to connect to socket
/tmp/dbus-K99gT9yDjS: Connection refused Falling back to non-factory
mode. Failed to summon the GConf demon; exiting. Failed to contact
configuration server; some possible causes are that you need to enable
TCP/IP networking for ORBit, or you have stale NFS locks due to a
system crash. See http://projects.gnome.org/gconf/ for information.
(Details – 1: Failed to get connection to session: Failed to connect
to socket /tmp/dbus-K99gT9yDjS: Connection refused)
How do I run gnome-terminal in this situation?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Indeed when an SSH session is open, it doesn’t launch a dbus session. Some programs may launch it, but then the session doesn’t know about it (hence can’t close it).
Not knowing about the dbus session also means that programs that use dbus but don’t launch it themselves will have problems.
dbus sections are per machine and per X11 display.
Their info is stored in $HOME/.dbus/session-bus/-
however, the process referenced there may be closed, so an extra check is needed to determine if launching dbus is needed or not.
Then, the variables there are to be exported to the session.
Then it works like a charm 🙂
I put the following in my .bash_profile file:
# set dbus for remote SSH connections
if [ -n "$SSH_CLIENT" -a -n "$DISPLAY" ]; then
machine_id=$(LANGUAGE=C hostnamectl|grep 'Machine ID:'| sed 's/^.*: //')
x_display=$(echo $DISPLAY|sed 's/^.*:([0-9]+)(.[0-9]+)*$/1/')
dbus_session_file="$HOME/.dbus/session-bus/${machine_id}-${x_display}"
if [ -r "$dbus_session_file" ]; then
export $(grep '^DBUS.*=' "$dbus_session_file")
# check if PID still running, if not launch dbus
ps $DBUS_SESSION_BUS_PID | tail -1 | grep dbus-daemon >& /dev/null
[ "$?" != "0" ] && export $(dbus-launch) >& /dev/null
else
export $(dbus-launch) >& /dev/null
fi
fi
notes: hostnamectl is part of systemd and allows to retrieve the machine-id
the dbus-launch displays the variables we want; by using export $(dbus-launch) we retrieve the output of dbus-launch and export the variables
Method 2
None of the previous answers worked in my case but launching the application through dbus-launch did the job:
ssh myhost "dbus-launch gnome-terminal --display localhost:10.0 &"
Method 3
I found this:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=639261
Which led me to try this:
$ sudo rm /var/lib/dbus/machine-id $ sudo service messagebus restart
Now I can run gnome-terminal!
Method 4
Just run:
> dbus-launch gnome-terminal
Method 5
Interesting… just restarting dbus didn’t work for me, I had to also remove the machine-id file as well as restart.
$ rcdbus stop $ rm /var/lib/dbus/machine-id $ rcdbus start
This was on a SLES 11.4 server that I had recently cloned in VMWare. My problem was I could not start yast2 or gedit…
These were the errors I was seeing on the command line:
yast2
** (y2controlcenter-gnome:9981): WARNING **: error accessing /desktop/gnome/lockdown/disable_command_line [Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://projects.gnome.org/gconf/ for information. (Details - 1: Failed to get connection to session: Failed to connect to socket /tmp/dbus-W7H31tbhVY: Connection refused)] ** (y2controlcenter-gnome:9981): WARNING **: GError raised: [Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://projects.gnome.org/gconf/ for information. (Details - 1: Failed to get connection to session: Failed to connect to socket /tmp/dbus-W7H31tbhVY: Connection refused)] user_message: [libslab_get_gconf_value: error getting /desktop/gnome/applications/main-menu/lock-down/user_modifiable_apps]
Thanks for the tip!
Method 6
Try this:
rm $HOME/.dbus/session-bus/*
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0