Sha256: 4030b0579021f2c8fbc9d1101ff69863c0ff2c7c4db0cfff27283525594ed456

Contents?: true

Size: 939 Bytes

Versions: 25

Compression:

Stored size: 939 Bytes

Contents

Capistrano::Configuration.instance(:must_exist).load do
  task :ssh do
    role = (ENV['ROLE'] || :app).to_sym
    servers = find_servers :roles => role
    server = servers.first
    if server
      `echo '#{password}' | /usr/bin/pbcopy`
      exec "/usr/bin/ssh #{user}@#{server.host} -p #{server.port || 22} "
    end
  end
  
  #namespace :ssh do
    task :tunnel do
      remote_port = ENV['REMOTE_PORT'] || 80
      local_port  = ENV['LOCAL_PORT']  || 2000
      role = (ENV['ROLE'] || :app).to_sym
      
      servers = find_servers :roles => role
      server = servers.first
      if server
        puts "Opening a tunnel from port #{local_port} locally to port #{remote_port} on #{server.host}"
        Net::SSH.start(server.host, user, :password => password, :port => server.port) do |ssh|
          ssh.forward.local(local_port, "127.0.0.1", remote_port)
          ssh.loop { true }
        end
      end
    end
  #end
  
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
factorylabs-fdlcap-0.1.0 lib/fdlcap/ssh.rb
factorylabs-fdlcap-0.2.0 lib/fdlcap/recipes/ssh.rb
factorylabs-fdlcap-0.2.1 lib/fdlcap/recipes/ssh.rb
factorylabs-fdlcap-0.2.2 lib/fdlcap/recipes/ssh.rb
factorylabs-fdlcap-0.2.3 lib/fdlcap/recipes/ssh.rb
factorylabs-fdlcap-0.2.4 lib/fdlcap/recipes/ssh.rb
factorylabs-fdlcap-0.2.5 lib/fdlcap/recipes/ssh.rb
factorylabs-fdlcap-0.2.6 lib/fdlcap/recipes/ssh.rb
factorylabs-fdlcap-0.2.7 lib/fdlcap/recipes/ssh.rb
factorylabs-fdlcap-0.3.0 lib/fdlcap/recipes/ssh.rb
factorylabs-fdlcap-0.3.1 lib/fdlcap/recipes/ssh.rb
factorylabs-fdlcap-0.3.10 lib/fdlcap/recipes/ssh.rb
factorylabs-fdlcap-0.3.11 lib/fdlcap/recipes/ssh.rb
factorylabs-fdlcap-0.3.15 lib/fdlcap/recipes/ssh.rb
factorylabs-fdlcap-0.3.16 lib/fdlcap/recipes/ssh.rb
factorylabs-fdlcap-0.3.17 lib/fdlcap/recipes/ssh.rb
factorylabs-fdlcap-0.3.18 lib/fdlcap/recipes/ssh.rb
factorylabs-fdlcap-0.3.2 lib/fdlcap/recipes/ssh.rb
factorylabs-fdlcap-0.3.3 lib/fdlcap/recipes/ssh.rb
factorylabs-fdlcap-0.3.4 lib/fdlcap/recipes/ssh.rb