capistrano - Initializing an ssh session from cap 3? -


i used use cap-ssh shortcut initiate ssh connection server, it doesn't works in capistrano 3 anymore.

does have suggestions starting ssh connection capistrano in cap 3?

you can define ssh task this:

desc 'start ssh session servers.' task :ssh   role = (env['role'] || :app).to_sym   on roles(role)     hosts = env.instance_variable_get(:@servers).instance_variable_get(:@servers)     hosts = hosts.select { |h| h.roles.include? role } if role     if hosts.size > 1       $stdout.puts "pick server connect to:"       hosts.each.with_index |host, i|         $stdout.puts "\t#{i + 1}: #{host.user}@#{host.hostname} role: #{host.roles.to_a}"       end       selected = $stdin.gets       selected = 1 if selected.empty?       host = hosts[selected.to_i - 1]     else       host = hosts.first     end     fail "no server defined!" unless host      port = host.netssh_options[:port] || fetch(:ssh_options) && fetch(:ssh_options)[:port] || 22     system "ssh -t -p #{port} #{host.user}@#{host.hostname} #{host.netssh_options[:forward_agent] ? '-a' : ''} 'cd #{current_path}; bash --login'"   end end 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -