Module: Capistrano::DemandForwardAgent

Extended by:
DemandForwardAgent
Includes:
Net::SSH::Authentication
Included in:
DemandForwardAgent
Defined in:
lib/capistrano/demand_forward_agent.rb,
lib/capistrano/demand_forward_agent/version.rb

Constant Summary collapse

SSHAgentError =
Class.new Capistrano::Error
SSHIdentityError =
Class.new Capistrano::Error
VERSION =
"0.0.1"

Instance Method Summary collapse

Instance Method Details

#confirmObject



13
14
15
16
17
# File 'lib/capistrano/demand_forward_agent.rb', line 13

def confirm
  set_ssh_option
  agent = connect_agent
  confirm_identity agent
end

#confirm_identity(agent) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/capistrano/demand_forward_agent.rb', line 33

def confirm_identity agent
  if agent.identities.length == 0
    raise SSHIdentityError.new 'Please run the `ssh-add` first.'
  end

  true
end

#connect_agentObject



23
24
25
26
27
28
29
30
31
# File 'lib/capistrano/demand_forward_agent.rb', line 23

def connect_agent
  begin
    agent = Agent.connect
  rescue AgentNotAvailable
    raise SSHAgentError.new 'Please run the `eval $(ssh-agent)` first.'
  end

  agent
end

#set_ssh_optionObject



19
20
21
# File 'lib/capistrano/demand_forward_agent.rb', line 19

def set_ssh_option
  ssh_options[:forward_agent] = true
end