Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9174981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:50:26+00:00 2026-06-17T16:50:26+00:00

We’re using Capistrano to automate pushing new versions of a PHP application to a

  • 0

We’re using Capistrano to automate pushing new versions of a PHP application to a production server. The production server (we’ll call it production) is public, while our repository server (we’ll call it repo) sits behind our corporate firewall, along with our own machines.

Capistrano, as configured by default, won’t work, as production can’t talk to repo.

I was wondering if there was someway I could setup capistrano to SSH to repo first, then SSH to production opening a tunnel on a port that I can then use to SSH from production back to repo to pull the changes from SCM.

I just can’t figure out how to set this up or figure out a better solution. Ideas?

Edit:

I’ve tried this:

role :web, "deploy.com"

namespace :deploy do
    task :remote_tunnel do
        run 'Creating SSH tunnel...' do |channel, stream, data|
            ssh = channel.connection
            ssh.forward.remote(22, 'server.com', 10000, '127.0.0.1')
            ssh.loop {!ssh.forward.active_remotes.include?([10000, '127.0.0.1'])}
        end
    end
end

before "deploy:update_code", "deploy:remote_tunnel"

But I keep getting this error:

failed: "sh -c 'Creating SSH tunnel...'" on deploy.com
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:50:27+00:00Added an answer on June 17, 2026 at 4:50 pm

    Here’s are 2 ways to accomplish it.

    1st way

    not sure if you’ve seen this thread?

    • https://groups.google.com/forum/?fromgroups=#!topic/capistrano/RVwMim-qnMg

    It makes use of the net-ssh-gateway library, but creates copies of the local forwarding methods but they’re geared for remote access.

    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
    

    2nd way

    Outlined in an answer to this SO question:

    • Is it possible to do have Capistrano do a checkout over a reverse SSH tunnel?

    This technique is very similar to the 1st way. First you need to create 2 paths to the repository:

    # deploy.rb
    set :local_repository, "ssh://git@serverbehindfirewall/path/to/project.git"
    set :repository,  "ssh://git@localhost:9000/path/to/project.git"
    

    Then before you deploy you’ll need to setup the remote forward:

    % ssh -R 9000:serverbehindfirewall:22 deploybot@deployserver.com
    # CTRL + C + A (Screen) or ⌘ + T (Terminal.app) to open new tab
    

    Followed by your deploy:

    % cap HOSTFILTER=deployserver.com deploy # HOSTFILTER reduces set to specified host. Only useful if you have multiple servers.
    

    See this answer to that SO question for more details:

    • https://stackoverflow.com/a/3953351/33204
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am using JSon response to parse title,date content and thumbnail images and place

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.