My setup is weird and I can't change it now. I have two machines:
local-machine: it's my desktop running Ubuntu with Gnome
remote-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
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.
- I can SSH normally from
local-machineusing my SSH key without any problems!
- I can run the command
DISPLAY=:0.0 gedit sftp://remote-machine/some/filein a terminal on
local-machineand gedit opens the file on
remote-machinewithout any problems - but the terminal in which I executed the command is running in DISPLAY :0 (really, it's
- I also tried
-toption 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/filein
local-machinebut under a tty (for example in
tty1, by pressing
<Ctrl>+<Alt>+<F1>) it doesn't not work - I get the same error when running from
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:
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?