Hi,
When trying to ssh login, to a host which has been reinstalled, using:
Net::SSH.start( value_hosts, USER, :password => PASS , :paranoid =>
false, :forward_agent => true ) do|ssh, err |
I am getting an error:
/sw/lib/ruby/gems/1.8/gems/net-ssh-1.1.1/lib/net/ssh/host-key-
verifier.rb:47:in `process_cache_miss’: fingerprint da:
34:2e:a6:87:c4:c8:49:0e:a1:8e:39:fd:fc:ef:e7 does not match for (Net::SSH::HostKeyMismatch)
Is there a way to Ignore HostKeyMismatch ?
Net::SSH.start( value_hosts, USER, :password => PASS , :paranoid =>
false, :forward_agent => true ) do|ssh, err |
is not working, i.e the :paranoid => false does not seem to work.
Any hint will be appreciated.
What i am trying to accomplish is to login via ssh, even of the ssh
exchange key is no longer valid since the OS was reinstalled.
i found the following, post but even that does not work:
in order to resolve the HostKeyMismatch, use following in irb:
require ‘rubygems’
require ‘net/ssh’
include Net
Net::SSH.start( ‘10.5.30.52’, ‘root’, :password => ‘password’ ,
:paranoid => false ) do|ssh|
#puts “hello”
end
rescue Net::SSH::HostKeyMismatch => e
puts “remembering new key: #{e.fingerprint}”
e.remember_host!
retry
end
i get an error:
irb(main):001:0> Net::SSH.start( ‘10.5.30.52’, ‘root’, :password =>
‘password’ , :paranoid => false ) do|ssh|
irb(main):002:1* #puts “hello”
irb(main):003:1* end
NameError: uninitialized constant Net
from (irb):1
from :0
irb(main):004:0> rescue Net::SSH::HostKeyMismatch => e
SyntaxError: compile error
(irb):4: syntax error, unexpected kRESCUE
rescue Net::SSH::HostKeyMismatch => e
^
(irb):4: syntax error, unexpected tASSOC
rescue Net::SSH::HostKeyMismatch => e
^
from (irb):4
from :0
irb(main):005:0> puts “remembering new key: #{e.fingerprint}”
NameError: undefined local variable or method e' for main:Object from (irb):5 from :0 irb(main):006:0> e.remember_host! NameError: undefined local variable or method
e’ for main:Object
from (irb):6
from :0
irb(main):007:0> retry
LocalJumpError: retry outside of rescue clause
from /usr/lib/ruby/1.8/irb/workspace.rb:81:in evaluate' from /usr/lib/ruby/1.8/irb/context.rb:219:in
evaluate’
from /usr/lib/ruby/1.8/irb.rb:150:in eval_input' from /usr/lib/ruby/1.8/irb.rb:263:in
signal_status’
from /usr/lib/ruby/1.8/irb.rb:147:in eval_input' from /usr/lib/ruby/1.8/irb/ruby-lex.rb:244:in
each_top_level_statement’
from /usr/lib/ruby/1.8/irb/ruby-lex.rb:230:in loop' from /usr/lib/ruby/1.8/irb/ruby-lex.rb:230:in
each_top_level_statement’
from /usr/lib/ruby/1.8/irb/ruby-lex.rb:229:in catch' from /usr/lib/ruby/1.8/irb/ruby-lex.rb:229:in
each_top_level_statement’
from /usr/lib/ruby/1.8/irb.rb:146:in eval_input' from /usr/lib/ruby/1.8/irb.rb:70:in
start’
from /usr/lib/ruby/1.8/irb.rb:69:in catch' from /usr/lib/ruby/1.8/irb.rb:69:in
start’
from /usr/bin/irb:13
Maybe IRB bug!!
irb(main):008:0> end
SyntaxError: compile error
(irb):8: syntax error, unexpected kEND
from (irb):8
from :0
irb(main):009:0>
Thanks,
-Kamal.