15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/webbynode/ssh.rb', line 15
def connect
raise "No IP given" unless @remote_ip
@conn = nil if @conn and @conn.closed?
@conn ||= Net::SSH.start(@remote_ip, @user, :port => @port, :auth_methods => %w(publickey hostbased))
rescue Net::SSH::AuthenticationFailed
HighLine.track_eof = false
begin
@password ||= ask("Enter your deployment password for #{@user}@#{@remote_ip}: ") { |q| q.echo = '' }
@conn ||= Net::SSH.start(@remote_ip, @user, :port => @port, :password => @password)
rescue Net::SSH::AuthenticationFailed
io.log "Could not connect to server: invalid authentication."
exit
end
rescue Net::SSH::Disconnect
io.log "Could not connect to the server: Wrong IP or Server Offline."
exit
end
|