sshfs doesn’t forward X + conflict with “ControlMaster auto”

Linux
Author

Vinh Nguyen

Published

May 12, 2011

I use sshfs to mount remote directories on my laptop to access files as if they are stored locally. I love it. I also use the ControlMaster feature of OpenSSH to reuse an existing ssh connection when opening new ssh connections to the same host.

The problem is that X11 Forwarding doesn't work with sshfs, at least not yet (don't think it will be updated since the last release was in 2008). This means that when the servers are mounted via sshfs, any subsequent ssh connection that issues -Y or -X will not have X11 forwarding. I discovered this by seeing some of these errors when I connect to remote servers even though I declared -Y -C:

$ firefox
Error: no display specified
$ xterm
xterm Xt error: Can't open display:
xterm: DISPLAY is not set
-bash: -sb: command not found
$ chromium-browser

(chromium-browser:14763): Gtk-WARNING **: cannot open display:

I posted this and this before figuring out it was an sshfs and ControlMaster problem.

Turning on X forwarding in ~/.ssh/config and /etc/ssh/ssh_config does not fix the problem.

My quick fix is to have additional URL's forward to the same servers (dyndns is free). Then use one set of URL's for sshfs, and the other for connecting to ssh with -Y -C. The computer thinks they are separate servers due to different names and so the connections are not shared.