diff options
author | ytti <saku@ytti.fi> | 2018-05-06 03:07:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-06 03:07:34 -0700 |
commit | fc1b600a2d09e99d4c0d3cfb4d8c0101cc9e640f (patch) | |
tree | 1fba35786a13b94757a76d4c15636ec65ed48385 | |
parent | e97a7707c45f30390d721d752d76fdb5d701c72d (diff) | |
parent | 8ed00a428fd173a3766a4c17e88adb3899e25380 (diff) |
Merge pull request #1266 from ja-frog/master
#1061 Handling devices that only prompt for password via SSH
-rw-r--r-- | lib/oxidized/input/ssh.rb | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/oxidized/input/ssh.rb b/lib/oxidized/input/ssh.rb index 6e86d13..e58d089 100644 --- a/lib/oxidized/input/ssh.rb +++ b/lib/oxidized/input/ssh.rb @@ -121,14 +121,13 @@ module Oxidized # some models have SSH auth or terminal auth based on version of code # if SSH is configured for terminal auth, we'll still try to detect prompt def login - if @username - match = expect username, @node.prompt - if match == username - cmd @node.auth[:username], password - cmd @node.auth[:password] - end - else - expect @node.prompt + match_re = [ @node.prompt ] + match_re << @username if @username + match_re << @password if @password + until (match=expect(match_re)) == @node.prompt + cmd(@node.auth[:username], nil) if match == @username + cmd(@node.auth[:password], nil) if match == @password + match_re.delete match end end |