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[] = {
"AddressFamily",
"BatchMode",
"BindAddress",
"ChallengeResponseAuthentication",
"CheckHostIP",
"Cipher",
"Ciphers",
"Compression",
"CompressionLevel",
"ConnectionAttempts",
"ConnectTimeout",
"ControlMaster",
"ControlPath",
"GlobalKnownHostsFile",
"GSSAPIAuthentication",
"GSSAPIDelegateCredentials",
"HostbasedAuthentication",
"HostKeyAlgorithms",
"HostKeyAlias",
"HostName",
"IdentitiesOnly",
"IdentityFile",
"KbdInteractiveAuthentication",
"KbdInteractiveDevices",
"LocalCommand",
"LogLevel",
"MACs",
"NoHostAuthenticationForLocalhost",
"NumberOfPasswordPrompts",
"PasswordAuthentication",
"Port",
"PreferredAuthentications",
"ProxyCommand",
"PubkeyAuthentication",
"RekeyLimit",
"RhostsRSAAuthentication",
"RSAAuthentication",
"ServerAliveCountMax",
"ServerAliveInterval",
"SmartcardDevice",
"StrictHostKeyChecking",
"TCPKeepAlive",
"UsePrivilegedPort",
"UserKnownHostsFile",
"VerifyHostKeyDNS",
NULL,
};
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:
CODE='
for i do
[ "$i" = -oClearAllForwardings=yes ] &&
i="-oLocalForward=127.0.0.5:3306 127.0.0.1:3306"
set -- "$@" "$i"
shift
done
exec ssh "$@"
' sshfs -o ssh_command='/bin/sh -c eval\\ "$CODE" sh' user@host:/path mnt