Answers: <p>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. </p>
  
  <p><a href="http://bencane.com/2014/02/18/sending-redis-traffic-through-an-ssl-tunnel-with-stunnel/" rel="nofollow noreferrer">http://bencane.com/2014/02/18/sending-redis-traffic-through-an-ssl-tunnel-with-stunnel/</a></p>
  
Answers: CC BY-SA 3.0
Answers: 2017-12-05T20:16:12.043Z
Answers: 2017-12-05T20:16:12.043Z
Answers: Jiri Klouda
Answers: <p>This works, I wonder if there is a better solution.
  SSH tunnel + nc proxy</p>
  
  <p><code>ssh $ssh_server -L $port:localhost:$port "mkfifo /tmp/backpipe; nc -k -l localhost $port 0&lt;/tmp/backpipe | nc $redis_server $port | 1&gt;/tmp/backpipe"</code></p>
  
Answers: CC BY-SA 3.0
Answers: 2017-12-05T14:26:14.653Z
Answers: 2017-12-05T14:26:14.653Z
Answers: Boris Churzin
Answers: <p>Assuming the following:</p>
  
  <ul>
  <li>YOUR_PC, has Redis client, SSH client, SSH access to SSH_SERVER</li>
  <li>SSH_SERVER, has SSH server, redis access to REDIS_SERVER</li>
  <li>REDIS_SERVER, has Redis server</li>
  </ul>
  
  <p>Set up the tunnel from YOUR_PC, port 1234, to REDIS_SERVER:REDIS_PORT, via SSH_SERVER</p>
  
  <pre><code>ssh SSH_SERVER -L 1234:REDIS_SERVER:REDIS_PORT
  </code></pre>
  
  <p>On another terminal, on YOUR_PC, run the redis client (based on <a href="https://stackoverflow.com/a/40678950">https://stackoverflow.com/a/40678950</a>):</p>
  
  <pre><code>redis-cli -h localhost -p 1234
  </code></pre>
  
Answers: CC BY-SA 3.0
Answers: 2017-12-05T17:17:15.067Z
Answers: 2017-12-05T20:53:30.437Z
Answers: 2017-12-05T20:53:30.437Z
Answers: Nitz
Body: <p>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 <code>redis-cli on my pc -&gt; ssh tunnel to the ssh machine -&gt; something -&gt; redis</code> so it would work.
  Is netcat + mkfifo the right way?
  Thanks :)</p>
  
Tags: <networking>
Title: SSH tunneling on steroids
UserDisplayName: Boris Churzin
ThreadText: # SSH tunneling on steroids
  
  (Asked by: username_0 on 2017-12-05)
  
  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 :)
  
  **Tags:** networking
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2017-12-05. Score: 6 | Accepted answer
  
  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
  
  ```
  ssh SSH_SERVER -L 1234:REDIS_SERVER:REDIS_PORT
  
  ```
  
  On another terminal, on YOUR\_PC, run the redis client (based on <https://stackoverflow.com/a/40678950>):
  
  ```
  redis-cli -h localhost -p 1234
  
  ```
  
  
  ---
  
  ### Answer by username_1 on 2017-12-05. Score: 2
  
  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.
  
  <http://bencane.com/2014/02/18/sending-redis-traffic-through-an-ssl-tunnel-with-stunnel/>
  
  
  ---
  
  ### Answer by username_0 on 2017-12-05. Score: 1
  
  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"`
  
  
  ---
  
  