I usually work in an X-forwarded GNOME Terminal session, which I launch like this:
local-machine$ ssh -X remote-machine gnome-terminal
I do this instead of running SSH in my local terminal because it means that new tabs will open on the remote host in the same directory (related unresolved question).
I've noticed that when I try to launch a GUI program from this X-forwarded terminal, it fails, e.g.
remote-machine$ gedit
(gedit:49577): Gtk-WARNING **: 14:32:45.928: cannot open display: localhost:13.0
However, if I also run a separate X-forwarded shell session (and just leave it sitting there):
local-machine$ ssh -X remote-machine
then I can run GUI apps like gedit
in the X-forwarded GNOME Terminal instance.
Why does this work-around work? Is there a simpler way to do this (e.g. a flag that I can add to the ssh -X remote-machine gnome-terminal
command)?