ever get an error like this?


/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 threestonehearth.com (Net::SSH::HostKeyMismatch)
        from /sw/lib/ruby/gems/1.8/gems/net-ssh-1.1.1/lib/net/ssh/host-key-verifier.rb:38:in `verify'
        from /sw/lib/ruby/gems/1.8/gems/net-ssh-1.1.1/lib/net/ssh/lenient-host-key-verifier.rb:9:in `verify'
        from /sw/lib/ruby/gems/1.8/gems/net-ssh-1.1.1/lib/net/ssh/transport/kex/dh.rb:165:in `verify_server_key'
        from /sw/lib/ruby/gems/1.8/gems/net-ssh-1.1.1/lib/net/ssh/transport/kex/dh.rb:232:in `exchange_keys'
        from /sw/lib/ruby/gems/1.8/gems/needle-1.3.0/lib/needle/lifecycle/proxy.rb:60:in `__send__'
        from /sw/lib/ruby/gems/1.8/gems/needle-1.3.0/lib/needle/lifecycle/proxy.rb:60:in `method_missing'
        from /sw/lib/ruby/gems/1.8/gems/net-ssh-1.1.1/lib/net/ssh/transport/session.rb:182:in `exchange_keys'
        from /sw/lib/ruby/gems/1.8/gems/net-ssh-1.1.1/lib/net/ssh/transport/session.rb:143:in `kexinit'
         ... 49 levels...
        from /sw/lib/ruby/gems/1.8/gems/capistrano-1.99.1/lib/capistrano/cli/execute.rb:14:in `execute'
        from /sw/lib/ruby/gems/1.8/gems/capistrano-1.99.1/bin/cap:4
        from /sw/bin/cap:16:in `load'
        from /sw/bin/cap:16

Run this fix in irb.

require 'rubygems'
require 'net/ssh'
include Net

domain = '######' # insert IP address or domain name here

begin
  Net::SSH.start( domain ) do |ssh|
    # ...
  end
rescue Net::SSH::HostKeyMismatch => e
  puts "remembering new key: #{e.fingerprint}" 
  e.remember_host!
  retry
end

Based on a post by Jamis Buck

1 Response to “fix Net::SSH error sometimes seen with capistrano”

  1. John Says:

    Excellent!

    You've saved my life, I was about to chuck the macbook thru the window.

    Thanks so much for posting this, really well done mate.

    John.

Leave a Reply