I have a remote redis machine with no ssh and no open ports except to the same lan + a remote machine (on the same lan) with ssh + my pc outside the lan. What I'm trying to do (mostly to see if it's possible) is redis-cli on my pc -> ssh tunnel to the ssh machine -> something -> redis so it would work. Is netcat + mkfifo the right way? Thanks :)


Assuming the following:

  • YOUR_PC, has Redis client, SSH client, SSH access to SSH_SERVER
  • SSH_SERVER, has SSH server, redis access to REDIS_SERVER
  • REDIS_SERVER, has Redis server

Set up the tunnel from YOUR_PC, port 1234, to REDIS_SERVER:REDIS_PORT, via SSH_SERVER


On another terminal, on YOUR_PC, run the redis client (based on https://stackoverflow.com/a/40678950):

redis-cli -h localhost -p 1234
| improve this answer | |

We have redis connected through stunnel. That way you don't have to always establish the ssh connection, which can be a problem. Here is an article on how to setup redis through stunnel, which I won't copy into this answer. Feel free to edit.


| improve this answer | |

This works, I wonder if there is a better solution. SSH tunnel + nc proxy

ssh $ssh_server -L $port:localhost:$port "mkfifo /tmp/backpipe; nc -k -l localhost $port 0</tmp/backpipe | nc $redis_server $port | 1>/tmp/backpipe"

| improve this answer | |

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.