title: How create port forwarding using SSHtunnelForwarder?
body: <p>I am trying to replicate: <code>ssh -i [KEY] -L [FROM_PORT]:localhost:[TO_PORT] ubuntu@[REMOTE_SERVER_IP]</code> in python and decided to use <code>sshtunnel</code> for it. The command given above works and I can connect to the remote Theia IDE, but I can't figure out how I need to configure <code>SSHtunnelForwarder</code> to achieve the same from within python. I am probably misunderstanding its documentation: <a href="https://github.com/pahaz/sshtunnel" rel="nofollow noreferrer">https://github.com/pahaz/sshtunnel</a></p>
  <p>EDIT: This code is faulty. Look for an answer below.</p>
  <pre><code>    # I replaced the remote-ip with `123.45.67.89`.
      # I replaced my ip with `987.65.43.21`.
      with SSHTunnelForwarder(
          ssh_address_or_host=&quot;123.45.67.89&quot;,  # ip of remote server
          ssh_pkey=&quot;PRIVATE_KEY&quot;, # I am unsure which one is needed tried both
          ssh_private_key=&quot;PRIVATE_KEY&quot;, # I am unsure which one is needed tried both
          ssh_username=&quot;ubuntu&quot;,  # username of remote server
          ssh_bind_address= (&quot;127.0.0.1&quot;, 9191),  # where to listen locally
          remote_bind_address= (&quot;127.0.0.1&quot;, 8181)  # where to send info coming to 22
          # ssh-port 22 (default port)
          # localhost:9191 -&gt; 123.45.67.89:22 -&gt; localhost:8181
          # which is basically 987.65.43.21:9191 -&gt; 123.45.67.89:22 -&gt; 123.45.67.89:8181
      ) as server:
          server.start()
  </code></pre>
  <p>But when I try to connect to <code>http://localhost:9191/</code> I receive unable to connect; so the tunneling is probably broken. I added plenty of comments to the code to make it easier to spot my misunderstanding.</p>