I've been using sshfs to mount directories from servers on my laptop.
I also have the following in my ~/.ssh/config:
ControlMaster auto
I set this because it keeps a single ssh connection alive whenever I
ssh into a server. I do this particularly for fast browsing in emacs
using tramp.
Since I have sshfs in my /etc/fstab, the ssh connection from sshfs is
the one that stays alive. A lot of times I also need X11 forwarding
(ssh -X -Y -C), and since I'm always using the original connection
from sshfs, X11 isn't forwarded.
X11 works when I remove the sshfs mount from my fstab, and I ssh into
my servers manually with the -X -Y -C option.
Is there a way to turn on -X -Y -C (or the likes) for sshfs? I tried adding
ForwardX11 yes
ForwardX11Trusted yes
in ~/.ssh/config and /etc/ssh/ssh_config to force the option to always
be on (might have security issue). However, sshfs in /etc/fstab does
not pick this up.
Do you have any suggestions? Thanks!
Best Answer
The way around this problem is to use script in place of ssh command.
man pages of sshfs (at least since 2.0 April 2008)
Like this:
And here's sshcmd
Adding something like this to fstab should allow automatic mounting of sshfs and enable forwarding. Do note that when mount happens it's usually root user so you might have to make appropriate changes to sshcmd (see last line of sshcmd).