I'm trying to add portforwarding to my sshfs-mount-scripts:

sshfs tim@devserver1:/ /home/tim/mnt/devserver1/ 
-o SSHOPT=LocalForward

So far I've failed using the correct syntax. Using brackets or commas instead of spaces did not work.

2 Answers 2


Unfortunately, that is not possible with -o. The list of ssh options supported by sshfs can be found in the source code:

static const char *ssh_opts[] = {

If it were supported, the syntax would be sshfs -o 'LocalForward=....'

In addition, sshfs passes the -oClearAllForwardings=yes option, so even the forwarding defined in ~/.ssh/config are not honoured.

Since sshfs supports passing a ssh_command, and allows additional arguments there, what you can do instead is:

  for i do
    [ "$i" = -oClearAllForwardings=yes ] &&
    set -- "$@" "$i"
  exec ssh "$@"
' sshfs -o ssh_command='/bin/sh -c eval\\ "$CODE" sh' user@host:/path mnt

just building on @Stéphane Chazelas answer sshfs passes the -oClearAllForwardings=yes option so any forwarding that is defined will not be honoured

so this behavior can be overwritten by passing -oClearAllForwarding=no instead, this can be done as follows

sshfs -o 'ssh_command=ssh -oClearAllForwardings=no' user@host:/path/to/remote/directory /path/to/local/directory

you can additionally pass the LocalForwarding option as follows:

sshfs -o 'ssh_command=ssh -oClearAllForwarding=no -L 3309:' user@host:/path/to/remote/directory /path/to/local/directory

shameless plug: I've written a script to simplify mounting with sshfs called sshmount it sets a few sane default options such as reconnect, ServerAliveInterval=15, sshfs_sync and sync_readdir based on my own experience with sshfs and a few tips i recently received and as of today it will also have an option -F to not clear all forwardings and an option -S to specify ssh options xD

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .