Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's are 2 ways to accomplish it.</p> <h2>1st way</h2> <p>not sure if you've seen this thread?</p> <ul> <li><a href="https://groups.google.com/forum/?fromgroups=#!topic/capistrano/RVwMim-qnMg" rel="nofollow noreferrer">https://groups.google.com/forum/?fromgroups=#!topic/capistrano/RVwMim-qnMg</a></li> </ul> <p>It makes use of the <code>net-ssh-gateway</code> library, but creates copies of the local forwarding methods but they're geared for remote access.</p> <pre><code>class Net::SSH::Gateway # Opens a SSH tunnel from a port on a remote host to a given host and port # on the local side # (equivalent to openssh -R parameter) def open_remote(port, host, remote_port, remote_host = "127.0.0.1") ensure_open! @session_mutex.synchronize do @session.forward.remote(port, host, remote_port, remote_host) end if block_given? begin yield [remote_port, remote_host] ensure close_remote(remote_port, remote_host) end else return [remote_port, remote_host] end rescue Errno::EADDRINUSE retry end # Cancels port-forwarding over an open port that was previously opened via # open_remote. def close_remote(port, host = "127.0.0.1") ensure_open! @session_mutex.synchronize do @session.forward.cancel_remote(port, host) end end end </code></pre> <h2>2nd way</h2> <p>Outlined in an answer to this SO question:</p> <ul> <li><a href="https://stackoverflow.com/questions/2729100/is-it-possible-to-do-have-capistrano-do-a-checkout-over-a-reverse-ssh-tunnel">Is it possible to do have Capistrano do a checkout over a reverse SSH tunnel?</a></li> </ul> <p>This technique is very similar to the 1st way. First you need to create 2 paths to the repository:</p> <pre><code># deploy.rb set :local_repository, "ssh://git@serverbehindfirewall/path/to/project.git" set :repository, "ssh://git@localhost:9000/path/to/project.git" </code></pre> <p>Then before you deploy you'll need to setup the remote forward:</p> <pre><code>% ssh -R 9000:serverbehindfirewall:22 deploybot@deployserver.com # CTRL + C + A (Screen) or ⌘ + T (Terminal.app) to open new tab </code></pre> <p>Followed by your deploy:</p> <pre><code>% cap HOSTFILTER=deployserver.com deploy # HOSTFILTER reduces set to specified host. Only useful if you have multiple servers. </code></pre> <p>See this answer to that SO question for more details: </p> <ul> <li><a href="https://stackoverflow.com/a/3953351/33204">https://stackoverflow.com/a/3953351/33204</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload