Class: Rig::Command::Ssh
Instance Method Summary
collapse
Methods inherited from Abstract
#instance_list, #print_table
Instance Method Details
#execute ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/rig/command/ssh.rb', line 6
def execute
unless user
puts "must set rig:ssh:user in configuration."
exit(1)
end
list = Rig::Model::Instance.find_by_nick(name)
if list.count == 0
puts "server not found."
elsif list.count > 1
puts "query returned more than one server:"
instance_list(list)
else
server = list.first
puts "connecting as #{user} to: #{server.tags['Name']} (#{server.public_ip_address})"
exec("ssh #{user}@#{server.public_ip_address}")
end
end
|