I'll apologise in advance, because I'm 90% sure this question has been asked somewhere before, but I can't figure this out, decide what's better and I'm completely unfamiliar with all of this.

My problem: On my school's network they blocked pretty much every port except for 21, 22 and 443, but I want to access my website's FTP server connection (hosted by some company) on port 7685 (which I can't change) to my local machine (a Mac). Preferably using SFTP of course.

Now my question is: what would be the most secure and fast method to be able to mount the sftp to my local machine on the school's network?

At home I can set up my Raspberry Pi to use as a middleman and direct all traffic from any port, so my idea was to use that as a proxy between my school's network. So I'll set it up to receive traffic from my local machine/school network on port 443 and direct it to the FTP server at port 7685.

I can imagine two possibilities: 1) mounting the FTP to my RPi over port 7685 and then mounting my RPi to my machine on the school network using port 443, but I fear this would slow down the connection (because of the extra hop). Or 2) using my RPi as a proxy (with something called SOCKS?) to mount my sftp directly to my machine on the school network, but I can't figure out how this works.

Or is there another way that I'm not seeing?

Things I can change: I can do everything with my RPi at home and all network preferences/firewall settings. My local computer's settings.

Things I can't change: The FTP server port/settings and my school's network preferences. (duh)

Many thanks in advance! (if there already is an answer somewhere, please send it to me, then I'll delete this post)


The solution described here worked.

To set up the proxy use


LOCAL_PORT being the port to forward to from local machine
TARGET_HOST the host you want to access (in my case my website FTP service)
TARGET_PORT the port of the host you want to access (in my case 7685)
INTERMEDIATE_USERNAME the username I use to log into my RPi/middleman
INTERMEDIATE_HOST the adres of my RPi at home (or whatever you use as middleman)
INTERMEDIATE_PORT the port I use to access my RPi/middleman (in my case 443)
-L to indicate we're forwarding a port from local
-N to prevent opening a shell login at INTERMEDIATE_HOST


ssh -L 8080:ftp.host.com:7685 pi@home.com -p 443 -N

This will have to stay running, so the following you need to do in a different window (or you can use -f, but you'll have to manually use kill to stop the proxy, see this question)

Then to connect SSH to REMOTE_HOST use


Or, in my case, to mount SFTP use SSHFS


TARGET_USERNAME being the username of my host
TARGET_PATH the path I need to use for my FTP service
LOCAL_PATH the path to mount the FTP to on local machine

Any feedback is greatly appreciated!

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.