I have some bridge host, which allows access to protected network. I connect to it using this command:

ssh sergius@bridge_host -D 3128

Thus, I can turn on socks proxy in browser and it works. I can login to hosts on that network with this command:

ssh -o 'ProxyCommand /bin/nc.openbsd -x localhost:3128 %h %p' sergius@any_internal_host

It works properly, but I can't mount via sshfs any of these hosts. Probably, I can't get how to use this ssh options in sshfs command. I tried even so silly tricks:

 sshfs -o "ssh_command=\"ssh -o 'ProxyCommand /bin/nc.openbsd -x localhost:3128 %h %p'\"" sergius@$host /home/sergius/work/SSHFS/$host/
 sshfs -o 'SSHOPT=ProxyCommand /bin/nc.openbsd -x localhost:3128 %h %p' sergius@$host: /home/sergius/work/SSHFS/$host/
 sshfs -o 'port=3128' sergius@$host: /home/sergius/work/SSHFS/$host/

One command returns "Connection reset by peer", another - unknown option `SSHOPT=ProxyCommand /bin/nc.openbsd -x localhost:3128 %h %p'

I didn't manage to find any info on the web. Please, help.


I feel so stupid, but still can't understand why I got such error:

 sshfs -d -o sshfs_debug -o LogLevel=DEBUG3 -o ProxyCommand="/bin/nc.openbsd --proxy localhost:3128 --proxy-type socks5 %h %p" sergius@$host:~ /home/sergius/work/SSHFS/$host/
 SSHFS version 2.4
 FUSE library version: 2.9.0
 nullpath_ok: 0
 nopath: 0
 utime_omit_ok: 0
 executing <ssh> <-x> <-a> <-oClearAllForwardings=yes> <-oLogLevel=DEBUG3> <-oProxyCommand=/bin/nc.openbsd --proxy localhost:3128 --proxy-type socks5 %h %p> <-2> <sergius@dev-host003> <-s> <sftp>
 debug1: Reading configuration data /etc/ssh/ssh_config
 debug1: /etc/ssh/ssh_config line 19: Applying options for *
 debug2: ssh_connect: needpriv 0
 debug1: Executing proxy command: exec /bin/nc.openbsd --proxy localhost:3128 --proxy-type socks5 dev-host003 22
 debug1: permanently_drop_suid: 1000
 debug1: identity file /home/sergius/.ssh/id_rsa type -1
 debug1: identity file /home/sergius/.ssh/id_rsa-cert type -1
 debug1: identity file /home/sergius/.ssh/id_dsa type -1
 debug1: identity file /home/sergius/.ssh/id_dsa-cert type -1
 debug1: identity file /home/sergius/.ssh/id_ecdsa type -1
 debug1: identity file /home/sergius/.ssh/id_ecdsa-cert type -1
 /bin/nc.openbsd: invalid option -- '-'
 usage: nc [-46bCDdhjklnrStUuvZz] [-I length] [-i interval] [-O length]
     [-P proxy_username] [-p source_port] [-q seconds] [-s source]
     [-T toskeyword] [-V rtable] [-w timeout] [-X proxy_protocol]
     [-x proxy_address[:port]] [destination] [port]
 ssh_exchange_identification: Connection closed by remote host
 read: Connection reset by peer


Wow! I managed to make it work!!! Great thanks for clarification with options. I read all allowed options and make it via "-x proxy_adress[:port]":

sshfs -o ProxyCommand="/bin/nc.openbsd -x localhost:3128  %h %p" sergius@$host:/home/sergius /home/sergius/work/SSHFS/$host/
  • I personally used sshfs in the past in servers, not fond of it. I also remember using it via ssh, and not being that complicated. I googled around and found this rdeeson.com/weblog/86/… – Rui F Ribeiro Dec 3 '15 at 12:50
  • 1
    Obviously, your nc doesn't support those --proxy/--proxy-type options – Stéphane Chazelas Dec 3 '15 at 14:53
  • So, what I should do - update nc? My OS - Debian 7 – Sergius Dec 3 '15 at 14:57

I was answering similar question not a long time ago. I didn't try it, but this one should work for you:

sshfs -o ProxyCommand="/bin/nc.openbsd --proxy localhost:3128 \
  --proxy-type socks5 %h %p" sergius@$host: /home/sergius/work/SSHFS/$host/

The SSHOPT=VAL just the format of option you want to use. You need to replace it with the specific key-value pair.

Also you need to tell the nc what type of proxy is that

| improve this answer | |
  • 1
    No, it doesn't work. Also - connection reset by peer – Sergius Dec 3 '15 at 14:31
  • so lets try to debug it with -d -o sshfs_debug -o LogLevel=DEBUG3 options and post in the edited question full output. Does the proxy work for other traffic? – Jakuje Dec 3 '15 at 14:32
  • With debug enabled: /bin/nc.openbsd: invalid option -- '-'. Use -X proxy_protocol and -x proxy_addres. manpages.debian.org/unstable/netcat-openbsd/nc.1.en.html , use: /bin/nc -X SOCKS5 -x %h %p – e-info128 Jan 31 at 0:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.