:paranoid => false
in the Net::SSH.start()开发者_C百科 does not seem to work
You can pass a Null verifier instead of false: :paranoid => Net::SSH::Verifiers::Null.new
.
This is essentially what you should get when passing false but it doesn't appear to always work for some reason.
Please note, just to be explicit. This does not ignore the HostKeyMismatch exception, rather it does not even attempt to verify the host key (the exception does not get raised at all).
Just to want to add one more thing to this.
You can also use remember_host
method of Net::SSH::HostKeyError
to record this host and key in the known hosts file.
Example :
begin
.
.
rescue Net::SSH::HostKeyError => e
e.remember_host!
retry
end
Source : http://www.rubydoc.info/github/net-ssh/net-ssh/Net/SSH/HostKeyError#remember_host!-instance_method
精彩评论