I am using a socks proxy on my office. This of course isnt a bug but a feature!
I want to mount a remote folder on a server outside my office dmz over ssh. So i ‘ve looked up for ssfs that mount an ssh remote folder with fuse (userspace). The main problem is that sshfs doesnt support any proxy settings! Thats a bummer.
So is there a way ?
From the command line i can pass sshfs through proxychains. But how can i do this through fstab ?
The normal entry on fstab is something like this:
sshfs#username@example.com:/home/username/folder/ /home/username/remote/folder/ fuse user,reconnect,compression=yes,ssh_protocol=2 0 0
and from cli is something like this:
proxychains sshfs username@example.com:/home/username/folder/ /home/username/remote/folder/ -C -o reconnect,ssh_protocol=2
That problem gave me a morning headache and i postponed everything i should be doing till i solved it.
And i solved it !!!
I didnt know that the first column in /etc/fstab can be a program or a shell script.
Do you ?
I learned it today, and i am extremely happy to learn linux stuffs with the old transitional way:
try & error.
So the above headache resolved by this entry on fstab:
proxysshfs /home/username/remote/folder/ fuse user,noauto 0 0
and this script: /usr/local/bin/proxysshfs
#!/bin/bash
unset http_proxy ; unset https_proxy ;
proxychains sshfs username@example.com:/home/username/folder/ /home/username/remote/folder/ -C -o reconnect,ssh_protocol=2
So now, everytime i am writing something like this:
mount /home/username/remote/folder/
my proxysshfs script is set in motion and the result is to execute the above command and finally mount the remote folder over ssh through a proxy.