1
My setup is weird and I can't change it now. I have two machines:
local-machine
: it's my desktop running Ubuntu with Gnomeremote-machine
: it's one virtual machine, also running Ubuntu but without X
In both machines I have my private and public SSH keys.
I need to run SSH from remote-machine
to local-machine
and run gedit (in local-machine
, under the default $DISPLAY) but openning a file in remote-machine
throught SFTP. Something like this:
myuser@remote-machine:~$ ssh local-machine "DISPLAY=:0.0 gedit sftp://remote-machine/some/file"
The command above doesn't work. gedit shows this message:
Could not open the file sftp://remote-machine/some/file.
gedit cannot handle sftp: locations.
Note that:
/some/file
exists onremote-machine
.- I can SSH normally from
remote-machine
tolocal-machine
using my SSH key without any problems! - I can run the command
DISPLAY=:0.0 gedit sftp://remote-machine/some/file
in a terminal onlocal-machine
and gedit opens the file onremote-machine
without any problems - but the terminal in which I executed the command is running in DISPLAY :0 (really, it'sgnome-terminal
). - I also tried
-t
option of SSH client (to force pseudo-tty allocation) but it didn't work. - If I try to run
DISPLAY=:0.0 gedit sftp://remote-machine/some/file
inlocal-machine
but under a tty (for example intty1
, by pressing<Ctrl>+<Alt>+<F1>
) it doesn't not work - I get the same error when running fromremote-machine
.
I found that if I pass the environment variable DBUS_SESSION_BUS_ADDRESS
with a correct value, it works! So, if I do something like that:
myuser@local-machine:~$ env | grep DBUS_SESSION_BUS_ADDRESS > env.txt
myuser@local-machine:~$ scp env.txt remote-machine:
and then:
myuser@remote-machine:~$ ssh local-machine "DISPLAY=:0.0 $(cat env.txt) gedit sftp://remote-machine/some/file"
it works! The problem is that I'm not on local-machine
so I can't get the correct value for this env variable. Is there any other way to make this work?