Sha256: 0f45e739a2aae1e52c9f01e48bc0d780e31a578f87a758c47d1de44748645fe8

Contents?: true

Size: 1.24 KB

Versions: 24

Compression:

Stored size: 1.24 KB

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
    ssh_cmd = fetch(:ssh_cmd, '/usr/bin/ssh')
    if server
      `echo '#{password}' | /usr/bin/pbcopy`
      exec "#{ssh_cmd} #{user}@#{server.host} -p #{server.port || 22} "
    end
  end
  
  task :ssh_forever do
    ssh_forever_binary = '/usr/bin/ssh-forever'
    if File.exists?(ssh_forever_binary)
      set :ssh_cmd, ssh_forever_binary
      ssh
    else
      puts "#{ssh_forever_binary} not found - do you have the ssh-forever gem installed?"
      exit 1
    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

24 entries across 24 versions & 2 rubygems

Version Path
factorylabs-fdlcap-0.3.27 lib/fdlcap/recipes/ssh.rb
factorylabs-fdlcap-0.3.28 lib/fdlcap/recipes/ssh.rb
fdlcap-0.4.17 lib/fdlcap/recipes/ssh.rb
fdlcap-0.4.15 lib/fdlcap/recipes/ssh.rb
fdlcap-0.4.14 lib/fdlcap/recipes/ssh.rb
fdlcap-0.4.13 lib/fdlcap/recipes/ssh.rb
fdlcap-0.4.12 lib/fdlcap/recipes/ssh.rb
fdlcap-0.4.11 lib/fdlcap/recipes/ssh.rb
fdlcap-0.4.10 lib/fdlcap/recipes/ssh.rb
fdlcap-0.4.9 lib/fdlcap/recipes/ssh.rb
fdlcap-0.4.7 lib/fdlcap/recipes/ssh.rb
fdlcap-0.4.6 lib/fdlcap/recipes/ssh.rb
fdlcap-0.4.5 lib/fdlcap/recipes/ssh.rb
fdlcap-0.4.4 lib/fdlcap/recipes/ssh.rb
fdlcap-0.4.3 lib/fdlcap/recipes/ssh.rb
fdlcap-0.4.2 lib/fdlcap/recipes/ssh.rb
fdlcap-0.4.0 lib/fdlcap/recipes/ssh.rb
fdlcap-0.3.35 lib/fdlcap/recipes/ssh.rb
fdlcap-0.3.34 lib/fdlcap/recipes/ssh.rb
fdlcap-0.3.33 lib/fdlcap/recipes/ssh.rb