Module: Net::SSH

Defined in:
lib/tinyssh.rb

Instance Method Summary collapse

Instance Method Details

#conn(*options) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/tinyssh.rb', line 9

def conn(*options)
  begin
    return Net::SSH.start(*options)
  rescue Timeout::Error
    return "\n#{OUTPUT_TITLE}\nHost : %s [ #{"Connecting Timeout".red} ] !\n"
  rescue Errno::EHOSTUNREACH
    return "\n#{OUTPUT_TITLE}\nHost : %s [ #{"Unreachable".red} ] !\n"
  rescue Errno::ECONNREFUSED
    return "\n#{OUTPUT_TITLE}\nHost : %s [ #{"Connection Refused".red} ] !\n"
  rescue Net::SSH::AuthenticationFailed
    return "\n#{OUTPUT_TITLE}\nHost : %s [ #{"Authentication Failure".red} ] !\n"
  rescue
    return "\n#{OUTPUT_TITLE}\nHost : %s [ #{"Name or Server not know".red} ] !\n"
  end
end