1

I've encountered multiple applications that don't support SSH tunneling, and that has become an issue when working off-site from our servers.

I have a Raspberry Pi sitting here which is never turned off, and was wondering if it is possible to route certain ports like 9200 (Elasticsearch) and 3306 (mysql) through an SSH tunnel to the remote servers?

I was able to achieve a connection with this command on the Raspberry Pi:

ssh -A -t -N -L 9200:localhost:9200 user@remoteserver

But it refuses to forward packets sent from my computer. It only works if I send packets as localhost on the Raspberry Pi.

Is there any way to forward the packets, and making this an ssh tunnel proxy server?

2

-g Allows remote hosts to connect to local forwarded ports

Add -g and then connect from your computer to the Raspberry Pi.

OR

Use ssh as SOCKS proxy with the -D switch. Eg. ssh -t -N -D 9000 user@remoteserver

Now you have a socks proxy on port 9000.

Run programs with a socks wrapper such as tsocks. Every TCP connection will go through the socks proxy and terminate on the remote server.

For HTTP, on a Raspberry Pi install an http proxy such as Polipo.

An example Polipo config:

proxyPort = 8118
socksParentProxy = "localhost:9000"
socksProxyType = socks5

Configure your web broswer to use the Raspberry Pi as a proxy server, http://rpi:8118

| improve this answer | |
  • Thank you so much. it worked! – Typewar Jul 3 '19 at 18:39

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.